Jump to solution
Verify

The Fix

Upgrade to version 0.13.0 or later.

Based on closed encode/httpx issue #504 · 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
@@ -57,7 +57,7 @@ def get_packages(package): "h2==3.*", "idna==2.*", - "rfc3986==1.*", + "rfc3986>=1.3,<2", "sniffio==1.*",
repro.py
❯ pip install httpx rfc3986==1.2 Requirement already satisfied: httpx in ./.pyenv/versions/3.8.0/lib/python3.8/site-packages (0.7.6) Collecting rfc3986==1.2 Using cached https://files.pythonhosted.org/packages/e1/59/1d547e9e5e1bf8074951067c3d6b31a2e29fd5b49bd7d32e53ff0da6406c/rfc3986-1.2.0-py2.py3-none-any.whl Requirement already satisfied: certifi in ./.pyenv/versions/3.8.0/lib/python3.8/site-packages (from httpx) (2019.9.11) Requirement already satisfied: chardet==3.* in ./.pyenv/versions/3.8.0/lib/python3.8/site-packages (from httpx) (3.0.4) Requirement already satisfied: idna==2.* in ./.pyenv/versions/3.8.0/lib/python3.8/site-packages (from httpx) (2.8) Requirement already satisfied: h11==0.8.* in ./.pyenv/versions/3.8.0/lib/python3.8/site-packages (from httpx) (0.8.1) Requirement already satisfied: hstspreload>=2019.8.27 in ./.pyenv/versions/3.8.0/lib/python3.8/site-packages (from httpx) (2019.10.31) Requirement already satisfied: h2==3.* in ./.pyenv/versions/3.8.0/lib/python3.8/site-packages (from httpx) (3.1.1) Requirement already satisfied: hyperframe<6,>=5.2.0 in ./.pyenv/versions/3.8.0/lib/python3.8/site-packages (from h2==3.*->httpx) (5.2.0) Requirement already satisfied: hpack<4,>=2.3 in ./.pyenv/versions/3.8.0/lib/python3.8/site-packages (from h2==3.*->httpx) (3.0.0) Installing collected packages: rfc3986 Found existing installation: rfc3986 1.3.0 Uninstalling rfc3986-1.3.0: Successfully uninstalled rfc3986-1.3.0 Successfully installed rfc3986-1.2.0 ~ took 4s ❯ python Python 3.8.0 (default, Oct 16 2019, 18:21:21) [Clang 11.0.0 (clang-1100.0.33.8)] on darwin Type "help", "copyright", "credits" or "license" for more information. >> import httpx >> httpx.get("https://httpbin.org") Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Users/florimond/.pyenv/versions/3.8.0/lib/python3.8/site-packages/httpx/api.py", line 122, in get return request( File "/Users/florimond/.pyenv/versions/3.8.0/lib/python3.8/site-packages/httpx/api.py", line 80, in request with Client(http_versions=["HTTP/1.1"]) as client: File "/Users/florimond/.pyenv/versions/3.8.0/lib/python3.8/site-packages/httpx/client.py", line 107, in __init__ self.base_url = URL("", allow_relative=True) File "/Users/florimond/.pyenv/versions/3.8.0/lib/python3.8/site-packages/httpx/models.py", line 108, in __init__ self._uri_reference = rfc3986.api.iri_reference(url).encode() AttributeError: module 'rfc3986.api' has no attribute 'iri_reference'
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.13.0 or later.\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: AttributeError: module 'rfc3986.api' has no attribute 'iri_reference'
  • Mechanism: The version requirement for rfc3986 was too low, causing compatibility issues with IRIs
  • Why the fix works: Fixed the version requirement for rfc3986 to ensure compatibility with IRIs, resolving AttributeError issues. (first fixed release: 0.13.0).
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).
  • The version requirement for rfc3986 was too low, causing compatibility issues with IRIs
  • Surfaces as: AttributeError: module 'rfc3986.api' has no attribute 'iri_reference'

Proof / Evidence

  • GitHub issue: #504
  • Fix PR: https://github.com/encode/httpx/pull/589
  • First fixed release: 0.13.0
  • Reproduced locally: No (not executed)
  • Last verified: 2026-02-09
  • Confidence: 0.75
  • Did this fix it?: Yes (upstream fix exists)
  • Own content ratio: 0.41

Discussion

High-signal excerpts from the issue thread (symptoms, repros, edge-cases).

“https://github.com/encode/httpx/blob/2fcf23bbfe41c5526cb35a65d32dd98dde786988/setup.py#L60 should become then?”
@StephenBrown2 · 2019-11-06 · source
“Can confirm this happening when installing rfc3986==1.2: 1.3.0 is fine, though — probably because iri_reference was introduced in 1.3, as indicated by the the rfc3986…”
@florimondmanca · 2019-11-06 · source
“Yep, rfc3986 didn't support IRIs pre 1.3 so we should probably mention that if we want to continue using rfc3986 as our URL parser.”
@sethmlarson · 2019-11-06 · source
“I saw this was still open. So i have raised a PR. Are we making sure the module version is less than 2, because of…”
@millefalcon · 2019-12-04 · source

Failure Signature (Search String)

  • AttributeError: module 'rfc3986.api' has no attribute 'iri_reference'

Error Message

Stack trace
error.txt
Error Message ------------- AttributeError: module 'rfc3986.api' has no attribute 'iri_reference'

Minimal Reproduction

repro.py
❯ pip install httpx rfc3986==1.2 Requirement already satisfied: httpx in ./.pyenv/versions/3.8.0/lib/python3.8/site-packages (0.7.6) Collecting rfc3986==1.2 Using cached https://files.pythonhosted.org/packages/e1/59/1d547e9e5e1bf8074951067c3d6b31a2e29fd5b49bd7d32e53ff0da6406c/rfc3986-1.2.0-py2.py3-none-any.whl Requirement already satisfied: certifi in ./.pyenv/versions/3.8.0/lib/python3.8/site-packages (from httpx) (2019.9.11) Requirement already satisfied: chardet==3.* in ./.pyenv/versions/3.8.0/lib/python3.8/site-packages (from httpx) (3.0.4) Requirement already satisfied: idna==2.* in ./.pyenv/versions/3.8.0/lib/python3.8/site-packages (from httpx) (2.8) Requirement already satisfied: h11==0.8.* in ./.pyenv/versions/3.8.0/lib/python3.8/site-packages (from httpx) (0.8.1) Requirement already satisfied: hstspreload>=2019.8.27 in ./.pyenv/versions/3.8.0/lib/python3.8/site-packages (from httpx) (2019.10.31) Requirement already satisfied: h2==3.* in ./.pyenv/versions/3.8.0/lib/python3.8/site-packages (from httpx) (3.1.1) Requirement already satisfied: hyperframe<6,>=5.2.0 in ./.pyenv/versions/3.8.0/lib/python3.8/site-packages (from h2==3.*->httpx) (5.2.0) Requirement already satisfied: hpack<4,>=2.3 in ./.pyenv/versions/3.8.0/lib/python3.8/site-packages (from h2==3.*->httpx) (3.0.0) Installing collected packages: rfc3986 Found existing installation: rfc3986 1.3.0 Uninstalling rfc3986-1.3.0: Successfully uninstalled rfc3986-1.3.0 Successfully installed rfc3986-1.2.0 ~ took 4s ❯ python Python 3.8.0 (default, Oct 16 2019, 18:21:21) [Clang 11.0.0 (clang-1100.0.33.8)] on darwin Type "help", "copyright", "credits" or "license" for more information. >> import httpx >> httpx.get("https://httpbin.org") Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Users/florimond/.pyenv/versions/3.8.0/lib/python3.8/site-packages/httpx/api.py", line 122, in get return request( File "/Users/florimond/.pyenv/versions/3.8.0/lib/python3.8/site-packages/httpx/api.py", line 80, in request with Client(http_versions=["HTTP/1.1"]) as client: File "/Users/florimond/.pyenv/versions/3.8.0/lib/python3.8/site-packages/httpx/client.py", line 107, in __init__ self.base_url = URL("", allow_relative=True) File "/Users/florimond/.pyenv/versions/3.8.0/lib/python3.8/site-packages/httpx/models.py", line 108, in __init__ self._uri_reference = rfc3986.api.iri_reference(url).encode() AttributeError: module 'rfc3986.api' has no attribute 'iri_reference'

Environment

  • Python: 3.7

What Broke

Users encountered an AttributeError when using httpx with incompatible rfc3986 versions.

Why It Broke

The version requirement for rfc3986 was too low, causing compatibility issues with IRIs

Fix Options (Details)

Option A — Upgrade to fixed release Safe default (recommended)

Upgrade to version 0.13.0 or later.

When NOT to use: Do not use if it changes public behavior or if the failure cannot be reproduced.

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/589

First fixed release: 0.13.0

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

  • Do not use if it changes public behavior or if the failure cannot be reproduced.

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.13.0 Fixed

Related Issues

No related fixes found.

Sources

We don’t republish the full GitHub discussion text. Use the links above for context.