fix: remove incorrect Start/Stop swap in ZRange Rev+ByScore/ByLex#979
Merged
rueian merged 2 commits intoredis:mainfrom Apr 6, 2026
Merged
fix: remove incorrect Start/Stop swap in ZRange Rev+ByScore/ByLex#979rueian merged 2 commits intoredis:mainfrom
rueian merged 2 commits intoredis:mainfrom
Conversation
Port of redis/go-redis#3751. Redis 6.2+ ZRANGE with REV expects the caller to supply the range in high-to-low order. The client-side swap was corrupting queries, causing ZRangeStore to return 0 instead of the correct count. Fixes redis#978 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Hi, I’m Jit, a friendly security platform designed to help developers build secure applications from day zero with an MVS (Minimal viable security) mindset. In case there are security findings, they will be communicated to you as a comment inside the PR. Hope you’ll enjoy using Jit. Questions? Comments? Want to learn more? Get in touch with us. |
Collaborator
|
Hi @tmchow, thanks! Could you fix the test? |
Missed updating 3 ZRangeArgs test calls in pipeline_test.go that still used old low-to-high ordering (Start: 1, Stop: 4) with Rev: true.
Contributor
Author
Fixed! |
rueian
approved these changes
Apr 6, 2026
Contributor
Author
|
Thanks @rueian ! |
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.

Summary
Ports redis/go-redis#3751 to rueidiscompat.
ZRangeStore(andzRangeArgs/ZRangeArgsWithScores) returned 0 instead of the correct count when usingRev: truewithByScoreorByLex. The client was swappingStart/Stopbefore sending to Redis, but Redis 6.2+ZRANGEwithREValready expects the caller to supply the range in high-to-low order.Removed the conditional swap in all three locations:
Compat.zRangeArgsCompat.ZRangeStoreCacheCompat.zRangeArgsUpdated affected tests to pass
Start/Stopin the correct high-to-low order.Before / After
Fixes #978
This contribution was developed with AI assistance (Codex).
Note
Medium Risk
Changes argument ordering sent to Redis for
ZRANGE/ZRANGESTOREwhen usingRevwithByScore/ByLex, which can affect query results and stored set contents if callers relied on the previous (incorrect) swap.Overview
Fixes
ZRangeArgs/ZRangeArgsWithScoresandZRangeStoreto always sendStartthenStopto Redis, removing the special-case swap previously done forRev+ByScore/ByLex(also applied to the cached adapter).Updates tests to pass
Start/Stopin the expected high-to-low order whenRev: true, aligning behavior with Redis 6.2+ZRANGE ... REVsemantics and correctingZRANGESTOREresult counts.Reviewed by Cursor Bugbot for commit 5f52ae6. Bugbot is set up for automated code reviews on this repo. Configure here.