Replace INCREX out-of-bounds policy to a single SATURATE option#15237
Merged
Conversation
sundb
commented
May 20, 2026
Comment on lines
-347
to
-367
| # --------------------------------------------------------------------- | ||
| # OVERFLOW REJECT: leave the key (and TTL) unchanged and reply | ||
| # [current_value, 0] when the result would be out of bounds, instead of | ||
| # producing an error. | ||
| # --------------------------------------------------------------------- | ||
|
|
||
| test {INCREX - BYINT REJECT on overflow leaves value unchanged, in-range applies normally} { | ||
| # llong overflow path | ||
| r set mykey 9223372036854775800 | ||
| assert_equal [r increx mykey BYINT 9223372036854775800 OVERFLOW REJECT] {9223372036854775800 0} | ||
| assert_equal [r get mykey] 9223372036854775800 | ||
| # UBOUND / LBOUND paths | ||
| r set mykey 10 | ||
| assert_equal [r increx mykey BYINT 100 UBOUND 15 OVERFLOW REJECT] {10 0} | ||
| assert_equal [r increx mykey BYINT -100 LBOUND 5 OVERFLOW REJECT] {10 0} | ||
| assert_equal [r get mykey] 10 | ||
| # In-range increment is applied normally | ||
| assert_equal [r increx mykey BYINT 3 UBOUND 20 OVERFLOW REJECT] {13 3} | ||
| assert_equal [r get mykey] 13 | ||
| } | ||
|
|
Collaborator
Author
There was a problem hiding this comment.
Since a large number of tests have already been done on the default policy, there is no longer any need for it.
tezc
reviewed
May 20, 2026
Co-authored-by: Ozan Tezcan <ozantezcan@gmail.com>
ShooterIT
reviewed
May 20, 2026
tezc
approved these changes
May 20, 2026
ShooterIT
approved these changes
May 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow #15045
Summary
Simplify INCREX's out-of-bounds policy:
The original INCREX shipped with three out-of-bounds policies — OVERFLOW FAIL, OVERFLOW SAT, OVERFLOW REJECT — but FAIL and REJECT are functionally redundant: both leave the key untouched when the result is out of bounds. They differ only in how the caller is notified (error reply vs. [current_value, 0] array reply), which forces the user to make a stylistic choice with no real semantic difference.
This PR collapses the three policies into one clear behavior:
New syntax:
Note
The syntax above was updated in #15237
Note
Medium Risk
Changes
INCREXclient-visible semantics and reply formats for out-of-bounds/overflow cases (errors become[current_value, 0]rejections), which may impact existing clients relying on previousOVERFLOWpolicies.Overview
INCREXno longer acceptsOVERFLOW <FAIL|SAT|REJECT>; it now supports a single optionalSATURATEflag in command metadata (commands.def,commands/increx.json) and in argument parsing.Runtime behavior in
increxCommandchanges so out-of-bounds/overflow operations default to a non-error rejection (key/TTL unchanged, reply[current_value, 0]), whileSATURATEclamps toLBOUND/UBOUND(or type limits) and proceeds. Tests are updated accordingly and the formerOVERFLOW REJECTcoverage is removed.Reviewed by Cursor Bugbot for commit c0f7ec6. Bugbot is set up for automated code reviews on this repo. Configure here.