The Fix
pip install redis==7.1.0
Based on closed redis/redis-py issue #2768 · PR/commit linked
Production note: This tends to surface only under concurrency. Reproduce with load tests and watch for lock contention/cancellation paths.
@@ -1,3 +1,4 @@
@@ -1,3 +1,4 @@
+ * Fix #2768, Fix KeyError: 'first-entry' in parse_xinfo_stream.
* Fix #2749, remove unnecessary __del__ logic to close connections.
* Fix #2754, adding a missing argument to SentinelManagedConnection
ERROR: Exception in ASGI application
Traceback (most recent call last):
.. fastapi stuff elided ...
File "/serve.py", line 187, in fetch_key
info = await r.xinfo_stream(key)
File "venv/lib/python3.9/site-packages/redis/asyncio/client.py", line 505, in execute_command
return await conn.retry.call_with_retry(
File "venv/lib/python3.9/site-packages/redis/asyncio/retry.py", line 59, in call_with_retry
return await do()
File "venv/lib/python3.9/site-packages/redis/asyncio/client.py", line 481, in _send_command_parse_response
return await self.parse_response(conn, command_name, **options)
File "venv/lib/python3.9/site-packages/redis/asyncio/client.py", line 536, in parse_response
retval = self.response_callbacks[command_name](response, **options)
File "venv/lib/python3.9/site-packages/redis/client.py", line 323, in parse_xinfo_stream
first = data["first-entry"]
KeyError: 'first-entry'
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: This fix should not be applied if the application relies on the strict presence of 'first-entry'.\n\n
Why This Fix Works in Production
- Trigger: ERROR: Exception in ASGI application
- Mechanism: The KeyError occurs due to the absence of 'first-entry' in the response data
- Why the fix works: Fixes a KeyError that occurs in the parse_xinfo_stream function when accessing 'first-entry'. (first fixed release: 7.1.0).
- If left unfixed, failures can be intermittent under concurrency (hard to reproduce; shows up as sporadic 5xx/timeouts).
Why This Breaks in Prod
- Shows up under Python 3.9 in real deployments (not just unit tests).
- The KeyError occurs due to the absence of 'first-entry' in the response data
- Surfaces as: ERROR: Exception in ASGI application
Proof / Evidence
- GitHub issue: #2768
- Fix PR: https://github.com/redis/redis-py/pull/2788
- First fixed release: 7.1.0
- Reproduced locally: No (not executed)
- Last verified: 2026-02-08
- Confidence: 0.85
- Did this fix it?: Yes (upstream fix exists)
- Own content ratio: 0.34
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“**Version**: redis-py 4.4.3, redis server 7.0.7 **Platform**: redis-py on various flavors of Linux (Debian and Ubuntu), redis server in AWS **Description**: Sometimes, I get this traceback: I haven't gotten it down to a reproducible test ca”
Failure Signature (Search String)
- ERROR: Exception in ASGI application
Error Message
Stack trace
Error Message
-------------
ERROR: Exception in ASGI application
Traceback (most recent call last):
.. fastapi stuff elided ...
File "/serve.py", line 187, in fetch_key
info = await r.xinfo_stream(key)
File "venv/lib/python3.9/site-packages/redis/asyncio/client.py", line 505, in execute_command
return await conn.retry.call_with_retry(
File "venv/lib/python3.9/site-packages/redis/asyncio/retry.py", line 59, in call_with_retry
return await do()
File "venv/lib/python3.9/site-packages/redis/asyncio/client.py", line 481, in _send_command_parse_response
return await self.parse_response(conn, command_name, **options)
File "venv/lib/python3.9/site-packages/redis/asyncio/client.py", line 536, in parse_response
retval = self.response_callbacks[command_name](response, **options)
File "venv/lib/python3.9/site-packages/redis/client.py", line 323, in parse_xinfo_stream
first = data["first-entry"]
KeyError: 'first-entry'
Minimal Reproduction
ERROR: Exception in ASGI application
Traceback (most recent call last):
.. fastapi stuff elided ...
File "/serve.py", line 187, in fetch_key
info = await r.xinfo_stream(key)
File "venv/lib/python3.9/site-packages/redis/asyncio/client.py", line 505, in execute_command
return await conn.retry.call_with_retry(
File "venv/lib/python3.9/site-packages/redis/asyncio/retry.py", line 59, in call_with_retry
return await do()
File "venv/lib/python3.9/site-packages/redis/asyncio/client.py", line 481, in _send_command_parse_response
return await self.parse_response(conn, command_name, **options)
File "venv/lib/python3.9/site-packages/redis/asyncio/client.py", line 536, in parse_response
retval = self.response_callbacks[command_name](response, **options)
File "venv/lib/python3.9/site-packages/redis/client.py", line 323, in parse_xinfo_stream
first = data["first-entry"]
KeyError: 'first-entry'
Environment
- Python: 3.9
What Broke
The application experiences intermittent failures when accessing stream information, leading to potential data access issues.
Why It Broke
The KeyError occurs due to the absence of 'first-entry' in the response data
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/2788
First fixed release: 7.1.0
Last verified: 2026-02-08. Validate in your environment.
When NOT to Use This Fix
- This fix should not be applied if the application relies on the strict presence of 'first-entry'.
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
- Add a stress test that runs high-concurrency workloads and fails on thread dumps / blocked locks.
- Enable watchdog dumps in prod (faulthandler, thread dump endpoint) to capture deadlocks quickly.
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.