Jump to solution
Verify

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%.

Jump to Verify Open PR/Commit
@@ -19,6 +19,8 @@ from ._exceptions import ( HTTPCORE_EXC_MAP, + InvalidURL, + RemoteProtocolError, RequestBodyUnavailable,
repro.py
>> 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.
verify
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
fix.md
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).
Production impact:
  • 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”
Issue thread Β· issue description Β· source

Failure Signature (Search String)

  • >> httpx.URL('https://πŸ˜‡/')

Error Message

Stack trace
error.txt
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

repro.py
>> 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.

When NOT to use: This fix should not be used if the URL is valid but not http/https.

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.

Get updates

We publish verified fixes weekly. No spam.

Subscribe

When NOT to Use This Fix

  • This fix should not be used if the URL is valid but not http/https.

Verify Fix

verify
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

VersionStatus
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.