Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Kyverno's sum function requires at least 1 element in the array #1291

Open
AlessandroPomponio opened this issue Jun 17, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@AlessandroPomponio
Copy link

Page link

https://kyverno.io/docs/writing-policies/jmespath/#sum

Description

The page mentions that the sum function in Kyverno is a custom version that has been augmented compared to the baseline JMESPath specification.

The page, however, does not mention the caveat that the sum function in Kyverno requires at least 1 element in the array, while the JMESPath specification says that the result should be 0.

This can be checked with the following: echo '{"input":[]}' | kyverno jp query "sum(input)"
And seen in the source code: https://github.com/kyverno/kyverno/blob/f7a962fd11846ebebf85e33cfaf85dc92f6d117e/pkg/engine/jmespath/functions.go#L858

Expected behavior

I would expect to see a note about this behaviour, as it deviates from the JMESPath spec

Slack discussion

No response

@AlessandroPomponio AlessandroPomponio added the bug Something isn't working label Jun 17, 2024
Copy link

welcome bot commented Jun 17, 2024

Thanks for opening your first issue here! Be sure to follow the issue template!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant