Skip to content

docs: fix the input types of the JMESPath arithmetic filters - #2212

Open
Kitio-Tek wants to merge 1 commit into
kyverno:mainfrom
Kitio-Tek:fix-jmespath-arithmetic-types
Open

Kitio-Tek wants to merge 1 commit into
kyverno:mainfrom
Kitio-Tek:fix-jmespath-arithmetic-types

Conversation

@Kitio-Tek

Copy link
Copy Markdown

Related issue

Closes #2211

Proposed Changes

The arithmetic tables on the JMESPath page still described the behavior from before kyverno/kyverno#5544:

  • add(): the table allowed mixing a number with a quantity or a duration, and a note said a number added to a duration counts as seconds. Both give a Types mismatch error now, so the table lists same-type inputs only and the note shows add('1h', '5s') instead.
  • subtract(): two quantities give a quantity (subtract('1Gi', '512Mi') is 512Mi), not a number. The section's own example, 10Mi minus 5Ki giving 10235Ki, already says so.
  • modulo(): two quantities or two durations work too (modulo('10Mi', '3Mi') is 1Mi), so they're added to the table.

I checked every row against Kyverno's JMESPath engine on main. The divide() and multiply() tables already match.

Checklist

  • I have read the contributing guidelines.
  • I have inspected the website preview for accuracy.
  • I have signed off my issue.

Since kyverno/kyverno#5544, add() and subtract() return a Types mismatch
error when a number is mixed with a quantity or a duration, and
subtracting two quantities returns a quantity. modulo() also accepts two
quantities or two durations. Update the add, subtract and modulo tables
and replace the note that said a number added to a duration counts as
seconds.

Signed-off-by: Myrian Koumgang <kmyriantek@gmail.com>
Copilot AI lite review requested due to automatic review settings October 22, 2026 20:50
@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Oct 22, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Update the add-demo fallback to a quantity-typed zero or another type-preserving fallback.

No open issues 🎉

What changed in this PR

This documentation-only pull request updates the JMESPath arithmetic filter reference to reflect Kyverno’s current type-handling behavior.

Changes:

  • Restricts add() to same-type operands and updates its example.
  • Adds quantity and duration support to the modulo() table.
  • Corrects quantity output for subtract().
  • The add-demo example still uses a numeric fallback that can cause a type mismatch with quantities and should be updated.
File Description
src/​content/​docs/​docs/​policy-types/​cluster-policy/​jmespath.md Corrects arithmetic filter input/output tables, examples, and related guidance.

Review effort: Lite

@Kitio-Tek

Copy link
Copy Markdown
Author

@aerosouund the add-demo fallback that Copilot flagged works as written: the `0` sits inside the quoted variable, so add() gets the string '0' and parses it as a quantity (with the 1.19.2 CLI the policy passes a Pod that only sets requests.memory and denies one with 100Mi requests plus 150Mi limits). Would a sentence saying that quoted numbers parse as quantities help here, or is the same-type note enough?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] JMESPath arithmetic tables list input types that return a Types mismatch error

2 participants