The Fix
pip install requests==2.32.0
Based on closed psf/requests issue #6533 · 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%.
@@ -1026,8 +1026,30 @@ library to use SSLv3::
block=block, ssl_version=ssl.PROTOCOL_SSLv3)
+Example: Automatic Retries
+^^^^^^^^^^^^^^^^^^^^^^^^^^
+
from requests import Session
from requests.adapters import HTTPAdapter
from requests.exceptions import RetryError
from urllib3.util import Retry
class LogRetry(Retry):
def __init__(self, *args, **kwargs):
total_retries = kwargs["total"]
print(f"Retry {total_retries} initiating...")
super().__init__(*args, **kwargs)
def test_case(retry_clazz, prefix):
s = Session()
s.mount(
prefix,
HTTPAdapter(
max_retries=retry_clazz(
total=3,
backoff_factor=0.1,
status_forcelist=[500],
allowed_methods={"POST"},
)
),
)
try:
print(f"Trying with retry class {retry_clazz}, prefix: {prefix}")
s.post("https://httpbin.org/status/500", {})
except RetryError:
print("Got the retry error, hooray!")
else:
print("Didn't get the retry error, oh no!")
test_case(Retry, "https://")
test_case(Retry, "")
test_case(LogRetry, "https://")
test_case(LogRetry, "")
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
Option A — Upgrade to fixed release\npip install requests==2.32.0\nWhen NOT to use: This fix is not applicable if the intended behavior is to allow empty prefix adapters.\n\n
Why This Fix Works in Production
- Trigger: status_forcelist=[500],
- Mechanism: Retries are ignored when an HTTPAdapter is bound to an empty string prefix
- Why the fix works: Added an example for implementing automatic retries in the Advanced Usage documentation of Requests. (first fixed release: 2.32.0).
- 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
- Retries are ignored when an HTTPAdapter is bound to an empty string prefix
- Production symptom (often without a traceback): from requests.exceptions import RetryError
Proof / Evidence
- GitHub issue: #6533
- Fix PR: https://github.com/psf/requests/pull/6258
- First fixed release: 2.32.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.44
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“We use the longest match and document that. So if you do not remove the other adapters this doesn't work and it is the intended…”
“Ah, you must be referring to the implicit adapters defined on Session instantiation at https://github.com/psf/requests/blob/881281250f74549f560408e5546d95a8cd73ce28/src/requests/sessions.py#L448”
Failure Signature (Search String)
- status_forcelist=[500],
Copy-friendly signature
Failure Signature
-----------------
from requests.exceptions import RetryError
status_forcelist=[500],
Error Message
Signature-only (no traceback captured)
Error Message
-------------
from requests.exceptions import RetryError
status_forcelist=[500],
Minimal Reproduction
from requests import Session
from requests.adapters import HTTPAdapter
from requests.exceptions import RetryError
from urllib3.util import Retry
class LogRetry(Retry):
def __init__(self, *args, **kwargs):
total_retries = kwargs["total"]
print(f"Retry {total_retries} initiating...")
super().__init__(*args, **kwargs)
def test_case(retry_clazz, prefix):
s = Session()
s.mount(
prefix,
HTTPAdapter(
max_retries=retry_clazz(
total=3,
backoff_factor=0.1,
status_forcelist=[500],
allowed_methods={"POST"},
)
),
)
try:
print(f"Trying with retry class {retry_clazz}, prefix: {prefix}")
s.post("https://httpbin.org/status/500", {})
except RetryError:
print("Got the retry error, hooray!")
else:
print("Didn't get the retry error, oh no!")
test_case(Retry, "https://")
test_case(Retry, "")
test_case(LogRetry, "https://")
test_case(LogRetry, "")
What Broke
Retries do not execute, leading to unhandled response errors in production.
Why It Broke
Retries are ignored when an HTTPAdapter is bound to an empty string prefix
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install requests==2.32.0
Use when you can deploy the upstream fix. It is usually lower-risk than long-lived workarounds.
Fix reference: https://github.com/psf/requests/pull/6258
First fixed release: 2.32.0
Last verified: 2026-02-08. Validate in your environment.
When NOT to Use This Fix
- This fix is not applicable if the intended behavior is to allow empty prefix adapters.
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 TLS smoke test that performs a real handshake in CI (include CA bundle validation and hostname checks).
- Alert on handshake failures by error string and endpoint to catch cert/CA changes quickly.
Version Compatibility Table
| Version | Status |
|---|---|
| 2.32.0 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.