website
website copied to clipboard
[Bug] Kyverno's `sum` function requires at least 1 element in the array
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