The Fix
pip install redis==7.1.0
Based on closed redis/redis-py issue #3052 · PR/commit linked
@@ -5017,14 +5017,16 @@ def hset(
if key is None and not mapping and not items:
raise DataError("'hset' with no key value pairs")
- items = items or []
+ pieces = []
+ if items:
from redis.client import Redis
redis = Redis.from_url('redis://127.0.0.1')
items = [
'one', b'1',
'two', b'2',
'three', b'3',
]
redis.hset('test', items=items, key='four', value=b'4')
print(items)
redis.close()
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
Option A — Upgrade to fixed release\npip install redis==7.1.0\nWhen NOT to use: Do not use this fix if the mutation of input lists is intended behavior.\n\n
Why This Fix Works in Production
- Trigger: Calling the method should, in principle, not change any of the objects sent as parameters.
- Mechanism: The `hset` method mutates the list passed to the `items` parameter when used with other parameters
- Why the fix works: `HSET` unexpectedly mutates the list passed to `items` was fixed by changing how parameters are handled. (first fixed release: 7.1.0).
- If left unfixed, this can cause silent data inconsistencies that propagate (bad cache entries, incorrect downstream decisions).
Why This Breaks in Prod
- The `hset` method mutates the list passed to the `items` parameter when used with other parameters
- Production symptom (often without a traceback): Calling the method should, in principle, not change any of the objects sent as parameters.
Proof / Evidence
- GitHub issue: #3052
- Fix PR: https://github.com/redis/redis-py/pull/3103
- First fixed release: 7.1.0
- Reproduced locally: No (not executed)
- Last verified: 2026-02-09
- Confidence: 0.95
- Did this fix it?: Yes (upstream fix exists)
- Own content ratio: 0.65
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“**Version**: redis-py 5.0.1 (Any Redis version) **Platform**: Any platform **Description**: If the items parameter of the hset or hmset method is used in conjunction with the key and value, or with the mapping parameters, the list passed to”
Failure Signature (Search String)
- Calling the method should, in principle, not change any of the objects sent as parameters.
- As a suggestion, the code could be changed to:
Copy-friendly signature
Failure Signature
-----------------
Calling the method should, in principle, not change any of the objects sent as parameters.
As a suggestion, the code could be changed to:
Error Message
Signature-only (no traceback captured)
Error Message
-------------
Calling the method should, in principle, not change any of the objects sent as parameters.
As a suggestion, the code could be changed to:
Minimal Reproduction
from redis.client import Redis
redis = Redis.from_url('redis://127.0.0.1')
items = [
'one', b'1',
'two', b'2',
'three', b'3',
]
redis.hset('test', items=items, key='four', value=b'4')
print(items)
redis.close()
What Broke
Unexpected mutation of input lists leads to incorrect data being processed.
Why It Broke
The `hset` method mutates the list passed to the `items` parameter when used with other parameters
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install redis==7.1.0
Use when you can deploy the upstream fix. It is usually lower-risk than long-lived workarounds.
Fix reference: https://github.com/redis/redis-py/pull/3103
First fixed release: 7.1.0
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- Do not use this fix if the mutation of input lists is intended behavior.
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.
Version Compatibility Table
| Version | Status |
|---|---|
| 7.1.0 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.