Jump to solution
Verify

The Fix

pip install redis==4.0.2

Based on closed redis/redis-py issue #1714 · 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%.

Jump to Verify Open PR/Commit
@@ -6,7 +6,8 @@ import time import warnings -from redis.commands import CoreCommands, RedisModuleCommands, list_or_args +from redis.commands import (CoreCommands, RedisModuleCommands, + SentinelCommands, list_or_args)
repro.py
It looks like the `Redis` client object returned when setting up the Sentinel class doesn't have access to the `sentinel_master` command found here https://github.com/redis/redis-py/blob/master/redis/commands/sentinel.py#L20 or any of the commands in that class. I have taken a look at the Redis class and can't find where `sentinel.py` is passing through the sentinel commands or where the `Redis` class in `client.py` is loading them. **Example**:
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==4.0.2\nWhen NOT to use: Do not use if it changes public behavior or if the failure cannot be reproduced.\n\n

Why This Fix Works in Production

  • Trigger: AttributeError: 'Redis' object has no attribute 'sentinel_masters'
  • Mechanism: The Redis client did not include SentinelCommands, leading to an AttributeError when calling discover_master
  • Why the fix works: Re-adds the functionality to run SentinelCommands using the Redis client returned when setting up the Sentinel class, fixing the AttributeError encountered in version 4.0.0. (first fixed release: 4.0.2).
Production impact:
  • 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.7.12 in real deployments (not just unit tests).
  • The Redis client did not include SentinelCommands, leading to an AttributeError when calling discover_master
  • Surfaces as: AttributeError: 'Redis' object has no attribute 'sentinel_masters'

Proof / Evidence

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

Discussion

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

“For anyone following, 4.0.2 has been released.”
@chayim · 2021-11-23 · confirmation · source
“For anyone else looking where this was fixed in 4.0.2 exactly, the related commit on master is https://github.com/redis/redis-py/commit/d2b233384458869270352b8c99ca682ae480da5f apparently.”
@hartwork · 2021-12-01 · confirmation · source
“> @chayim Could we please yank the faulty release? @thedrow that would not play nice with people who have pinned it somewhere, and it's advised…”
@hartwork · 2022-01-03 · source
“Thank you @sculley for reporting, and fixing this! What a great community”
@chayim · 2021-11-18 · source

Failure Signature (Search String)

  • AttributeError: 'Redis' object has no attribute 'sentinel_masters'

Error Message

Stack trace
error.txt
Error Message ------------- AttributeError: 'Redis' object has no attribute 'sentinel_masters'
Stack trace
error.txt
Error Message ------------- Traceback (most recent call last):\n File "<stdin>", line 1, in <module>\n File "/usr/local/lib/python3.7/site-packages/redis/sentinel.py", line 234, in discover_master\n masters = sentinel.sentinel_masters()

Minimal Reproduction

repro.py
It looks like the `Redis` client object returned when setting up the Sentinel class doesn't have access to the `sentinel_master` command found here https://github.com/redis/redis-py/blob/master/redis/commands/sentinel.py#L20 or any of the commands in that class. I have taken a look at the Redis class and can't find where `sentinel.py` is passing through the sentinel commands or where the `Redis` class in `client.py` is loading them. **Example**:

Environment

  • Python: 3.7.12

What Broke

Users experienced AttributeError when attempting to discover Redis master using Sentinel.

Why It Broke

The Redis client did not include SentinelCommands, leading to an AttributeError when calling discover_master

Fix Options (Details)

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

pip install redis==4.0.2

When NOT to use: Do not use if it changes public behavior or if the failure cannot be reproduced.

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/1723

First fixed release: 4.0.2

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

  • Do not use if it changes public behavior or if the failure cannot be reproduced.

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

  • Make timeouts explicit and test them (unit + integration) to avoid silent behavior changes.
  • Instrument retries (attempt count + reason) and alert on spikes to catch dependency slowdowns.

Version Compatibility Table

VersionStatus
4.0.2 Fixed

Related Issues

No related fixes found.

Sources

We don’t republish the full GitHub discussion text. Use the links above for context.