The Fix
Adds the `score_cast_func` argument to the `zrevrank` function for consistency with the `zrevrange` function, addressing the inconsistency reported in issue #3300.
Based on closed redis/redis-py issue #3300 · PR/commit linked
Production note: Most teams hit this during upgrades or environment changes. Roll out with a canary and smoke critical endpoints (health, OpenAPI/docs) before 100%.
@@ -94,7 +94,7 @@ jobs:
python-compatibility-tests:
runs-on: ubuntu-latest
- needs: [ redis_version, tests ]
+ needs: [ redis_version ]
timeout-minutes: 60
def zrevrange(
self,
name: KeyT,
start: int,
end: int,
withscores: bool = False,
score_cast_func: Union[type, Callable] = float,
) -> ResponseT:
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
Option A — Apply the official fix\nAdds the `score_cast_func` argument to the `zrevrank` function for consistency with the `zrevrange` function, addressing the inconsistency reported in issue #3300.\nWhen NOT to use: This fix should not be applied if backward compatibility with existing code is a concern.\n\n
Why This Fix Works in Production
- Trigger: Why does the `zrevrange` function offer the flexibility of `score_cast_func` while `zrevrank` does not? Given the similar nature of these functions, shouldn’t…
- Mechanism: The zrevrank function lacked a score_cast_func parameter, causing inconsistency with zrevrange
- If left unfixed, the same config can fail only in production (env differences), causing startup failures or partial feature outages.
Why This Breaks in Prod
- The zrevrank function lacked a score_cast_func parameter, causing inconsistency with zrevrange
- Production symptom (often without a traceback): Why does the `zrevrange` function offer the flexibility of `score_cast_func` while `zrevrank` does not? Given the similar nature of these functions, shouldn’t they both support the same score casting logic for consistency?
Proof / Evidence
- GitHub issue: #3300
- Fix PR: https://github.com/redis/redis-py/pull/3795
- Reproduced locally: No (not executed)
- Last verified: 2026-02-12
- Confidence: 0.80
- Did this fix it?: Yes (upstream fix exists)
- Own content ratio: 0.72
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“This issue has been automatically marked as stale due to inactivity. It will be closed in 30 days if no further activity occurs. If you…”
Failure Signature (Search String)
- Why does the `zrevrange` function offer the flexibility of `score_cast_func` while `zrevrank` does not? Given the similar nature of these functions, shouldn’t they both support
Copy-friendly signature
Failure Signature
-----------------
Why does the `zrevrange` function offer the flexibility of `score_cast_func` while `zrevrank` does not? Given the similar nature of these functions, shouldn’t they both support the same score casting logic for consistency?
Error Message
Signature-only (no traceback captured)
Error Message
-------------
Why does the `zrevrange` function offer the flexibility of `score_cast_func` while `zrevrank` does not? Given the similar nature of these functions, shouldn’t they both support the same score casting logic for consistency?
Minimal Reproduction
def zrevrange(
self,
name: KeyT,
start: int,
end: int,
withscores: bool = False,
score_cast_func: Union[type, Callable] = float,
) -> ResponseT:
What Broke
Inconsistent score casting led to incorrect data handling in production code.
Why It Broke
The zrevrank function lacked a score_cast_func parameter, causing inconsistency with zrevrange
Fix Options (Details)
Option A — Apply the official fix
Adds the `score_cast_func` argument to the `zrevrank` function for consistency with the `zrevrange` function, addressing the inconsistency reported in issue #3300.
Fix reference: https://github.com/redis/redis-py/pull/3795
Last verified: 2026-02-12. Validate in your environment.
When NOT to Use This Fix
- This fix should not be applied if backward compatibility with existing code is a concern.
Verify Fix
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
Did This Fix Work in Your Case?
Quick signal helps us prioritize which fixes to verify and improve.
Prevention
- Capture the exact failing error string in logs and tests so you can reproduce via a minimal script.
- Pin production dependencies and upgrade only with a reproducible test that hits the failing path.
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.