The Fix
Restores zrange functionality for older versions of Redis by reverting changes made in a previous pull request.
Based on closed redis/redis-py issue #1669 · 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%.
@@ -2520,6 +2520,13 @@ def zrange(self, name, start, end, desc=False, withscores=False,
Can't be provided when using ``bylex``.
"""
+ # Need to support ``desc`` also when using old redis version
+ # because it was supported in 3.5.3 (of redis-py)
+ if not byscore and not bylex and (offset is None and num is None) \
Option A — Apply the official fix\nRestores zrange functionality for older versions of Redis by reverting changes made in a previous pull request.\nWhen NOT to use: Do not use if it changes public behavior or if the failure cannot be reproduced.\n\nOption B — Safe version pin\npip install redis==3.5.3\nWhen NOT to use: Do not use if you need features or security fixes in newer releases.\n\n
Why This Fix Works in Production
- Trigger: 4.0.0rc1 breaks various zrange commands on older servers
- Mechanism: The zrange command syntax changed to use unsupported options for older Redis servers
- 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
- Shows up under Python 3.8 in real deployments (not just unit tests).
- The zrange command syntax changed to use unsupported options for older Redis servers
- Production symptom (often without a traceback): 4.0.0rc1 breaks various zrange commands on older servers
Proof / Evidence
- GitHub issue: #1669
- Fix PR: https://github.com/redis/redis-py/pull/1697
- Reproduced locally: No (not executed)
- Last verified: 2026-02-11
- Confidence: 0.60
- 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).
“@chayim looks like this was broken by #1603.”
“Thanks @bmerry for tracking this down all the way. We'll definitely get this into rc2! @AvitalFineRedis while we're here, let's test for this case.”
“@chayim the following is still broken in 4.0.0rc2 (but worked in 3.5.3):”
“@AvitalFineRedis can you add a test with this specific case? Our 6.0.0 testing didn't seem to cover this. @bmerry thanks again, for highlighting this.”
Failure Signature (Search String)
- 4.0.0rc1 breaks various zrange commands on older servers
Copy-friendly signature
Failure Signature
-----------------
4.0.0rc1 breaks various zrange commands on older servers
@chayim looks like this was broken by #1603.
Error Message
Signature-only (no traceback captured)
Error Message
-------------
4.0.0rc1 breaks various zrange commands on older servers
@chayim looks like this was broken by #1603.
Environment
- Python: 3.8
What Broke
Older Redis servers return syntax errors when using zrange with new options.
Why It Broke
The zrange command syntax changed to use unsupported options for older Redis servers
Fix Options (Details)
Option A — Apply the official fix
Restores zrange functionality for older versions of Redis by reverting changes made in a previous pull request.
Option B — Safe version pin Backward-compatible pin
pip install redis==3.5.3
Use when you can’t upgrade immediately. Plan a follow-up to upgrade (pins can accumulate security/compat debt).
Fix reference: https://github.com/redis/redis-py/pull/1697
Last verified: 2026-02-11. Validate in your environment.
When NOT to Use This Fix
- Do not use if it changes public behavior or if the failure cannot be reproduced.
- Do not use if you need features or security fixes in newer releases.
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.
Version Compatibility Table
| Version | Status |
|---|---|
| 3.5.3 | Working |
| 4.0.0 | Broken |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.