Jump to solution
Verify

The Fix

pip install redis==7.1.0

Based on closed redis/redis-py issue #1238 · PR/commit linked

Jump to Verify Open PR/Commit
@@ -389,11 +389,12 @@ def parse_zscan(response, **options): def parse_slowlog_get(response, **options): + space = ' ' if options.get('decode_responses', False) else b' ' return [{ 'id': item[0],
repro.py
Traceback (most recent call last): File "<input>", line 1, in <module> File "/Users/.../lib/python3.7/site-packages/redis/client.py", line 1192, in slowlog_get return self.execute_command(*args) File "/Users/.../lib/python3.7/site-packages/redis/client.py", line 839, in execute_command return self.parse_response(conn, command_name, **options) File "/Users/.../lib/python3.7/site-packages/redis/client.py", line 859, in parse_response return self.response_callbacks[command_name](response, **options) File "/Users/.../lib/python3.7/site-packages/redis/client.py", line 397, in parse_slowlog_get } for item in response] File "/Users/.../lib/python3.7/site-packages/redis/client.py", line 397, in <listcomp> } for item in response] TypeError: sequence item 0: expected a bytes-like object, str found
verify
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
fix.md
Option A — Upgrade to fixed release\npip install redis==7.1.0\nWhen NOT to use: This fix is not applicable if decode_responses is not needed or if the application relies on raw byte responses.\n\n

Why This Fix Works in Production

  • Trigger: return self.execute_command(*args)
  • Mechanism: TypeError occurs in slowlog_get() due to incorrect handling of response types when decode_responses=True
  • Why the fix works: Fixes a TypeError in slowlog_get() by passing the optional decode_responses argument down to parse_slowlog_get(). (first fixed release: 7.1.0).

Why This Breaks in Prod

  • Shows up under Python 3.7.5 in real deployments (not just unit tests).
  • TypeError occurs in slowlog_get() due to incorrect handling of response types when decode_responses=True
  • Surfaces as: Traceback (most recent call last):

Proof / Evidence

  • GitHub issue: #1238
  • Fix PR: https://github.com/redis/redis-py/pull/1239
  • First fixed release: 7.1.0
  • Reproduced locally: No (not executed)
  • Last verified: 2026-02-07
  • Confidence: 0.85
  • Did this fix it?: Yes (upstream fix exists)
  • Own content ratio: 0.42

Discussion

High-signal excerpts from the issue thread (symptoms, repros, edge-cases).

“**Version**: redis-py 3.3.11 and AWS ElastiCache Redis 5.0.5 (Cluster mode off, 1 shard, 2 nodes) **Platform**: Python 3.7.5 on macOS Catalina 10.15.1 **Description**: Calling slowlog_get() on a redis.Redis client instance with decode_respo”
Issue thread · issue description · source

Failure Signature (Search String)

  • return self.execute_command(*args)

Error Message

Stack trace
error.txt
Error Message ------------- Traceback (most recent call last): File "<input>", line 1, in <module> File "/Users/.../lib/python3.7/site-packages/redis/client.py", line 1192, in slowlog_get return self.execute_command(*args) File "/Users/.../lib/python3.7/site-packages/redis/client.py", line 839, in execute_command return self.parse_response(conn, command_name, **options) File "/Users/.../lib/python3.7/site-packages/redis/client.py", line 859, in parse_response return self.response_callbacks[command_name](response, **options) File "/Users/.../lib/python3.7/site-packages/redis/client.py", line 397, in parse_slowlog_get } for item in response] File "/Users/.../lib/python3.7/site-packages/redis/client.py", line 397, in <listcomp> } for item in response] TypeError: sequence item 0: expected a bytes-like object, str found

Minimal Reproduction

repro.py
Traceback (most recent call last): File "<input>", line 1, in <module> File "/Users/.../lib/python3.7/site-packages/redis/client.py", line 1192, in slowlog_get return self.execute_command(*args) File "/Users/.../lib/python3.7/site-packages/redis/client.py", line 839, in execute_command return self.parse_response(conn, command_name, **options) File "/Users/.../lib/python3.7/site-packages/redis/client.py", line 859, in parse_response return self.response_callbacks[command_name](response, **options) File "/Users/.../lib/python3.7/site-packages/redis/client.py", line 397, in parse_slowlog_get } for item in response] File "/Users/.../lib/python3.7/site-packages/redis/client.py", line 397, in <listcomp> } for item in response] TypeError: sequence item 0: expected a bytes-like object, str found

Environment

  • Python: 3.7.5

What Broke

TypeError prevents retrieval of slow log entries, impacting monitoring and debugging capabilities.

Why It Broke

TypeError occurs in slowlog_get() due to incorrect handling of response types when decode_responses=True

Fix Options (Details)

Option A — Upgrade to fixed release Safe default (recommended)

pip install redis==7.1.0

When NOT to use: This fix is not applicable if decode_responses is not needed or if the application relies on raw byte responses.

Use when you can deploy the upstream fix. It is usually lower-risk than long-lived workarounds.

Option D — Guard side-effects with OnceOnly Guardrail for side-effects

Mitigate duplicate external side-effects under retries/timeouts/agent loops by gating the operation before calling external systems.

  • Place OnceOnly between your code/agent and real side-effects (Stripe, emails, CRM, APIs).
  • Use a stable key per side-effect (e.g., customer_id + action + idempotency_key).
  • Fail-safe: configure fail-open vs fail-closed based on blast radius and spend risk.
Show example snippet (optional)
onceonly.py
from onceonly import OnceOnly import os once = OnceOnly(api_key=os.environ["ONCEONLY_API_KEY"], fail_open=True) # Stable idempotency key per real side-effect. # Use a request id / job id / webhook delivery id / Stripe event id, etc. event_id = "evt_..." # replace key = f"stripe:webhook:{event_id}" res = once.check_lock(key=key, ttl=3600) if res.duplicate: return {"status": "already_processed"} # Safe to execute the side-effect exactly once. handle_event(event_id)

See OnceOnly SDK

When NOT to use: Do not use this to hide logic bugs or data corruption. Use it to block duplicate external side-effects and enforce tool permissions/spend caps.

Fix reference: https://github.com/redis/redis-py/pull/1239

First fixed release: 7.1.0

Last verified: 2026-02-07. Validate in your environment.

Get updates

We publish verified fixes weekly. No spam.

Subscribe

When NOT to Use This Fix

  • This fix is not applicable if decode_responses is not needed or if the application relies on raw byte responses.
  • Do not use this to hide logic bugs or data corruption. Use it to block duplicate external side-effects and enforce tool permissions/spend caps.

Verify Fix

verify
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

VersionStatus
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.