The Fix
Upgrade to version 0.14.2 or later.
Based on closed encode/httpx issue #1203 · PR/commit linked
@@ -411,9 +411,8 @@ def encoding(self, value: str) -> None:
"""
Returns a list of the raw header items, as byte pairs.
- May be mutated in-place.
"""
- return self._list
>> import httpx
>> client = httpx.Client()
>> request = client.build_request("GET", "https://google.com")
>> requests.headers
Headers({'host': 'google.com', 'user-agent': 'python-httpx/0.14.1', 'accept': '*/*', 'accept-encoding': 'gzip, deflate, br', 'connection': 'keep-alive'})
>> "host" in request.headers
False
>> request.headers.pop("host")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "D:\programs\anaconda3\lib\_collections_abc.py", line 801, in pop
del self[key]
File "E:\projects\pycharm\httpx\httpx\_models.py", line 536, in __delitem__
del self._dict[del_key]
KeyError: b'host'
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
Option A — Upgrade to fixed release\nUpgrade to version 0.14.2 or later.\nWhen NOT to use: Do not use this fix if the header behavior is expected to remain unchanged.\n\n
Why This Fix Works in Production
- Trigger: >> import httpx
- Mechanism: Fixes the issue where auto headers were inserted into headers._list but not into headers._dict.
- Why the fix works: Fixes the issue where auto headers were inserted into headers._list but not into headers._dict. (first fixed release: 0.14.2).
- If left unfixed, this can cause silent data inconsistencies that propagate (bad cache entries, incorrect downstream decisions).
Why This Breaks in Prod
- Surfaces as: >> import httpx
Proof / Evidence
- GitHub issue: #1203
- Fix PR: https://github.com/encode/httpx/pull/1205
- First fixed release: 0.14.2
- 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).
“Introduced by #1089. Resolved and test case'd in #1205.”
Failure Signature (Search String)
- >> import httpx
Error Message
Stack trace
Error Message
-------------
>> import httpx
>> client = httpx.Client()
>> request = client.build_request("GET", "https://google.com")
>> requests.headers
Headers({'host': 'google.com', 'user-agent': 'python-httpx/0.14.1', 'accept': '*/*', 'accept-encoding': 'gzip, deflate, br', 'connection': 'keep-alive'})
>> "host" in request.headers
False
>> request.headers.pop("host")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "D:\programs\anaconda3\lib\_collections_abc.py", line 801, in pop
del self[key]
File "E:\projects\pycharm\httpx\httpx\_models.py", line 536, in __delitem__
del self._dict[del_key]
KeyError: b'host'
Minimal Reproduction
>> import httpx
>> client = httpx.Client()
>> request = client.build_request("GET", "https://google.com")
>> requests.headers
Headers({'host': 'google.com', 'user-agent': 'python-httpx/0.14.1', 'accept': '*/*', 'accept-encoding': 'gzip, deflate, br', 'connection': 'keep-alive'})
>> "host" in request.headers
False
>> request.headers.pop("host")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "D:\programs\anaconda3\lib\_collections_abc.py", line 801, in pop
del self[key]
File "E:\projects\pycharm\httpx\httpx\_models.py", line 536, in __delitem__
del self._dict[del_key]
KeyError: b'host'
What Broke
Headers were not accessible as expected, leading to KeyError on header access.
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
Upgrade to version 0.14.2 or later.
Use when you can deploy the upstream fix. It is usually lower-risk than long-lived workarounds.
Fix reference: https://github.com/encode/httpx/pull/1205
First fixed release: 0.14.2
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- Do not use this fix if the header behavior is expected to remain unchanged.
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.
Version Compatibility Table
| Version | Status |
|---|---|
| 0.14.2 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.