[Bug] Kyverno's sum
function requires at least 1 element in the array
#1291
Labels
bug
Something isn't working
sum
function requires at least 1 element in the array
#1291
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
The text was updated successfully, but these errors were encountered: