The Fix
pip install urllib3==1.26.0
Based on closed urllib3/urllib3 issue #2014 · 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%.
@@ -155,7 +155,7 @@ def __setitem__(self, key, val):
def __getitem__(self, key):
val = self._container[key.lower()]
- return ", ".join([six.ensure_str(v, "ascii") for v in val[1:]])
+ return ", ".join(val[1:])
# -*- coding: utf-8 -*-
import json
import urllib3
user_agent = u'Test-Service-Client (Schönefeld - SXF) - 1.18.0'.encode('iso-8859-1')
http = urllib3.PoolManager()
r = http.request('GET', 'https://httpbin.org/get', headers={'User-Agent': user_agent})
print(r.status)
print(json.loads(r.data)) # Displays correctly in Python3, escaped string in Python 2
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
Option A — Upgrade to fixed release\npip install urllib3==1.26.0\nWhen NOT to use: Do not use this fix if your application relies on the previous header encoding behavior.\n\n
Why This Fix Works in Production
- Trigger: r = requests.get('https://httpbin.org/get', headers={'User-Agent': user_agent})
- Mechanism: The change in header encoding caused issues with iso-8859-1 characters in headers
- Why the fix works: Adds a SKIP_HEADER feature to skip automatically added headers, addressing the issues raised in #2014. (first fixed release: 1.26.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
- The change in header encoding caused issues with iso-8859-1 characters in headers
- Surfaces as: File "test.py", line 13, in <module>
Proof / Evidence
- GitHub issue: #2014
- Fix PR: https://github.com/urllib3/urllib3/pull/2018
- First fixed release: 1.26.0
- Reproduced locally: No (not executed)
- Last verified: 2026-02-09
- Confidence: 0.85
- Did this fix it?: Yes (upstream fix exists)
- Own content ratio: 0.37
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“Thanks for reporting this. We might have to either find a better way to implement #1930 and #1933 or revert those PRs.”
“We decided to revert the change that caused this issue for v1.x”
Failure Signature (Search String)
- r = requests.get('https://httpbin.org/get', headers={'User-Agent': user_agent})
Error Message
Stack trace
Error Message
-------------
File "test.py", line 13, in <module>
r = requests.get('https://httpbin.org/get', headers={'User-Agent': user_agent})
File "/Users/nateprewitt/Work/OpenSource/requests/requests/api.py", line 76, in get
return request('get', url, params=params, **kwargs)
File "/Users/nateprewitt/Work/OpenSource/requests/requests/api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
File "/Users/nateprewitt/Work/OpenSource/requests/requests/sessions.py", line 542, in request
resp = self.send(prep, **send_kwargs)
File "/Users/nateprewitt/Work/OpenSource/requests/requests/sessions.py", line 655, in send
r = adapter.send(request, **kwargs)
File "/Users/nateprewitt/Work/OpenSource/requests/requests/adapters.py", line 449, in send
timeout=timeout
File "/Users/nateprewitt/Work/OpenSource/urllib3/src/urllib3/connectionpool.py", line 710, in urlopen
chunked=chunked,
File "/Users/nateprewitt/Work/OpenSource/urllib3/src/urllib3/connectionpool.py", line 400, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/Users/nateprewitt/Work/OpenSource/urllib3/src/urllib3/connection.py", line 221, in request
elif headers["user-agent"] == SUPPRESS_USER_AGENT:
File "/Users/nateprewitt/Work/OpenSource/urllib3/src/urllib3/_collections.py", line 158, in __getitem__
return ", ".join([six.ensure_str(v, "ascii") for v
... (truncated) ...
Minimal Reproduction
# -*- coding: utf-8 -*-
import json
import urllib3
user_agent = u'Test-Service-Client (Schönefeld - SXF) - 1.18.0'.encode('iso-8859-1')
http = urllib3.PoolManager()
r = http.request('GET', 'https://httpbin.org/get', headers={'User-Agent': user_agent})
print(r.status)
print(json.loads(r.data)) # Displays correctly in Python3, escaped string in Python 2
Environment
- urllib3: 1.25.10
What Broke
Requests with non-ASCII headers fail, resulting in incorrect responses.
Why It Broke
The change in header encoding caused issues with iso-8859-1 characters in headers
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install urllib3==1.26.0
Use when you can deploy the upstream fix. It is usually lower-risk than long-lived workarounds.
Fix reference: https://github.com/urllib3/urllib3/pull/2018
First fixed release: 1.26.0
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- Do not use this fix if your application relies on the previous header encoding behavior.
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 CI check that diffs key outputs after upgrades (OpenAPI schema snapshots, JSON payload shapes, CLI output).
- Upgrade behind a canary and run integration tests against the canary before 100% rollout.
- Track RSS + object counts after deployments; alert on monotonic growth and GC pressure.
- Add a long-running test that repeats the failing call path and asserts stable memory.
Version Compatibility Table
| Version | Status |
|---|---|
| 1.26.0 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.