The Fix
Upgrade to version 0.14.1 or later.
Based on closed encode/httpx issue #1158 Β· 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%.
@@ -19,6 +19,8 @@
from ._exceptions import (
HTTPCORE_EXC_MAP,
+ InvalidURL,
+ RemoteProtocolError,
RequestBodyUnavailable,
>> httpx.URL('https://π/')
Traceback (most recent call last):
File "/Users/tomchristie/Temp/venv/lib/python3.7/site-packages/rfc3986/iri.py", line 125, in idna_encoder
std3_rules=True)
File "/Users/tomchristie/Temp/venv/lib/python3.7/site-packages/idna/core.py", line 360, in encode
s = alabel(label)
File "/Users/tomchristie/Temp/venv/lib/python3.7/site-packages/idna/core.py", line 281, in alabel
check_label(label)
File "/Users/tomchristie/Temp/venv/lib/python3.7/site-packages/idna/core.py", line 261, in check_label
raise InvalidCodepoint('Codepoint {0} at position {1} of {2} not allowed'.format(_unot(cp_value), pos+1, repr(label)))
idna.core.InvalidCodepoint: Codepoint U+1F607 at position 3 of 'ððπ' not allowed
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/tomchristie/Temp/venv/lib/python3.7/site-packages/httpx/_models.py", line 69, in __init__
self._uri_reference = rfc3986.api.iri_reference(url).encode()
File "/Users/tomchristie/Temp/venv/lib/python3.7/site-packages/rfc3986/iri.py", line 133, in encode
for part in self.host.split(".")])
File "/Users/tomchristie/Temp/venv/lib/python3.7/site-packages/rfc3986/iri.py", line 133, in <listcomp>
for part in self.host.split(".")])
File "/Users/tomchristie/Temp/venv/lib/python3.7/site-packages/rfc3986/iri.py", line 127, in idna_encoder
raise exceptions.InvalidAuthority(self.authority)
rfc3986.exceptions.InvalidAuthority: The authority (ððπ) is not valid.
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.1 or later.\nWhen NOT to use: This fix should not be used if the URL is valid but not http/https.\n\n
Why This Fix Works in Production
- Trigger: >> httpx.URL('https://π/')
- Mechanism: Maps the rfc3986.exceptions.InvalidAuthority exception to httpx.InvalidURL, improving error handling for improperly formed URLs.
- Why the fix works: Maps the rfc3986.exceptions.InvalidAuthority exception to httpx.InvalidURL, improving error handling for improperly formed URLs. (first fixed release: 0.14.1).
- 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 in real deployments (not just unit tests).
- Surfaces as: >> httpx.URL('https://π/')
Proof / Evidence
- GitHub issue: #1158
- Fix PR: https://github.com/encode/httpx/pull/1163
- First fixed release: 0.14.1
- 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.24
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
βWe're wrapping our underlying h11/h2 library exception classes, but we're currently missing an rfc3986 case... We should reintroduce the InvalidURL exception for URLs that really are improperly formed and *cannot* be parsed (not our previouβ
Failure Signature (Search String)
- >> httpx.URL('https://π/')
Error Message
Stack trace
Error Message
-------------
>> httpx.URL('https://π/')
Traceback (most recent call last):
File "/Users/tomchristie/Temp/venv/lib/python3.7/site-packages/rfc3986/iri.py", line 125, in idna_encoder
std3_rules=True)
File "/Users/tomchristie/Temp/venv/lib/python3.7/site-packages/idna/core.py", line 360, in encode
s = alabel(label)
File "/Users/tomchristie/Temp/venv/lib/python3.7/site-packages/idna/core.py", line 281, in alabel
check_label(label)
File "/Users/tomchristie/Temp/venv/lib/python3.7/site-packages/idna/core.py", line 261, in check_label
raise InvalidCodepoint('Codepoint {0} at position {1} of {2} not allowed'.format(_unot(cp_value), pos+1, repr(label)))
idna.core.InvalidCodepoint: Codepoint U+1F607 at position 3 of 'ððπ' not allowed
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/tomchristie/Temp/venv/lib/python3.7/site-packages/httpx/_models.py", line 69, in __init__
self._uri_reference = rfc3986.api.iri_reference(url).encode()
File "/Users/tomchristie/Temp/venv/lib/python3.7/site-packages/rfc3986/iri.py", line 133, in encode
for part in self.host.split(".")])
File "/Users/tomchristie/Temp/venv/lib/python3.7/site-packages/rfc3986/iri.py", line 133, in <listcomp>
for part in self.host.split(".")])
File "/Users/tomchristie/Temp/venv/lib/python3.7/site
... (truncated) ...
Minimal Reproduction
>> httpx.URL('https://π/')
Traceback (most recent call last):
File "/Users/tomchristie/Temp/venv/lib/python3.7/site-packages/rfc3986/iri.py", line 125, in idna_encoder
std3_rules=True)
File "/Users/tomchristie/Temp/venv/lib/python3.7/site-packages/idna/core.py", line 360, in encode
s = alabel(label)
File "/Users/tomchristie/Temp/venv/lib/python3.7/site-packages/idna/core.py", line 281, in alabel
check_label(label)
File "/Users/tomchristie/Temp/venv/lib/python3.7/site-packages/idna/core.py", line 261, in check_label
raise InvalidCodepoint('Codepoint {0} at position {1} of {2} not allowed'.format(_unot(cp_value), pos+1, repr(label)))
idna.core.InvalidCodepoint: Codepoint U+1F607 at position 3 of 'ððπ' not allowed
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/tomchristie/Temp/venv/lib/python3.7/site-packages/httpx/_models.py", line 69, in __init__
self._uri_reference = rfc3986.api.iri_reference(url).encode()
File "/Users/tomchristie/Temp/venv/lib/python3.7/site-packages/rfc3986/iri.py", line 133, in encode
for part in self.host.split(".")])
File "/Users/tomchristie/Temp/venv/lib/python3.7/site-packages/rfc3986/iri.py", line 133, in <listcomp>
for part in self.host.split(".")])
File "/Users/tomchristie/Temp/venv/lib/python3.7/site-packages/rfc3986/iri.py", line 127, in idna_encoder
raise exceptions.InvalidAuthority(self.authority)
rfc3986.exceptions.InvalidAuthority: The authority (ððπ) is not valid.
Environment
- Python: 3.7
What Broke
Users encountered unhandled exceptions when providing improperly formed URLs.
Fix Options (Details)
Option A β Upgrade to fixed release Safe default (recommended)
Upgrade to version 0.14.1 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/1163
First fixed release: 0.14.1
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- This fix should not be used if the URL is valid but not http/https.
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.1 | Fixed |
Related Issues
No related fixes found.
Sources
We donβt republish the full GitHub discussion text. Use the links above for context.