The Fix
2.0 is intended to be the next release, so this should be fixed in the wild fairly soon.
Based on closed psf/requests issue #1607
Production note: This usually shows up under retries/timeouts. Treat it as a side-effect risk until you can verify behavior with a canary + real traffic.
>> from requests.structures import CaseInsensitiveDict
>> d = CaseInsensitiveDict()
>> d[b'Content-Type'] = 'text/html'
>> 'Content-Type' in d
False
>> d['Content-Type'] = 'application/json'
>> d
CaseInsensitiveDict({b'Content-Type': 'text/html', 'Content-Type': 'application/json'})
>>
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
Option A — Apply the official fix\n2.0 is intended to be the next release, so this should be fixed in the wild fairly soon.\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: CaseInsensitiveDict problem with python3 result in duplicated Content-Type/Length headers
- Mechanism: 2.0 is intended to be the next release, so this should be fixed in the wild fairly soon.
- If left unfixed, this can cause silent data inconsistencies that propagate (bad cache entries, incorrect downstream decisions).
Why This Breaks in Prod
- Production symptom (often without a traceback): CaseInsensitiveDict problem with python3 result in duplicated Content-Type/Length headers
Proof / Evidence
- GitHub issue: #1607
- Reproduced locally: No (not executed)
- Last verified: 2026-02-04
- Confidence: 0.00
- Did this fix it?: No (no upstream fix linked)
- Own content ratio: 0.60
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“Thanks for raising this issue! We've known about this bug for some time, and had a fix ready for a long time (see #1338)”
Failure Signature (Search String)
- CaseInsensitiveDict problem with python3 result in duplicated Content-Type/Length headers
- Headers are stored in a CaseInsensitiveDict but this class accept both bytes and str as key in python3. This result in duplicated headers when you want to provide
Copy-friendly signature
Failure Signature
-----------------
CaseInsensitiveDict problem with python3 result in duplicated Content-Type/Length headers
Headers are stored in a CaseInsensitiveDict but this class accept both bytes and str as key in python3. This result in duplicated headers when you want to provide Content-Type/Length by yourself.
Error Message
Signature-only (no traceback captured)
Error Message
-------------
CaseInsensitiveDict problem with python3 result in duplicated Content-Type/Length headers
Headers are stored in a CaseInsensitiveDict but this class accept both bytes and str as key in python3. This result in duplicated headers when you want to provide Content-Type/Length by yourself.
Minimal Reproduction
>> from requests.structures import CaseInsensitiveDict
>> d = CaseInsensitiveDict()
>> d[b'Content-Type'] = 'text/html'
>> 'Content-Type' in d
False
>> d['Content-Type'] = 'application/json'
>> d
CaseInsensitiveDict({b'Content-Type': 'text/html', 'Content-Type': 'application/json'})
>>
Fix Options (Details)
Option A — Apply the official fix
2.0 is intended to be the next release, so this should be fixed in the wild fairly soon.
Fix reference: https://github.com/psf/requests/issues/1607
When NOT to Use This Fix
- Do not use if it changes public behavior or if the failure cannot be reproduced.
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.
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.