Jump to solution
Verify

The Fix

Upgrade to version 0.13.0 or later.

Based on closed encode/httpx issue #864 · PR/commit linked

Production note: This usually shows up under retries/timeouts. Treat it as a side-effect risk until you can verify behavior with a canary + real traffic.

Jump to Verify Open PR/Commit
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). +## 0.12.1 (March 19th, 2020) + +### Fixed
repro.py
In [1]: import httpx ...: from httpx.exceptions import InvalidURL In [2]: try: ...: httpx.get("foo.bar") ...: except InvalidURL: ...: pass ...:
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: This fix should not be used if the application relies on the old module structure.\n\n

Why This Fix Works in Production

  • Trigger: ...: from httpx.exceptions import InvalidURL
  • Mechanism: Resolves a packaging issue in version 0.12.0 where additional files were being included.
  • Why the fix works: Resolves a packaging issue in version 0.12.0 where additional files were being included. (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).
  • Production symptom (often without a traceback): ...: from httpx.exceptions import InvalidURL

Proof / Evidence

  • GitHub issue: #864
  • Fix PR: https://github.com/encode/httpx/pull/868
  • First fixed release: 0.13.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.67

Discussion

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

“Okay doke, let roll a re-release due to packaging issues.”
@lovelydinosaur · 2020-03-16 · source
“To extract a working code sample from florimondmanca's prose, this should work: As should this, though less recommended:”
@StephenBrown2 · 2020-03-13 · source
“I'll close for now, but if you keep encountering issues if switching to httpx.<...> then feel free to report. :-) Thanks!”
@florimondmanca · 2020-03-13 · source
“Thanks for the quick response”
@kbakk · 2020-03-13 · source

Failure Signature (Search String)

  • ...: from httpx.exceptions import InvalidURL
  • In 0.12.0 the exception isn't caught:
Copy-friendly signature
signature.txt
Failure Signature ----------------- ...: from httpx.exceptions import InvalidURL In 0.12.0 the exception isn't caught:

Error Message

Signature-only (no traceback captured)
error.txt
Error Message ------------- ...: from httpx.exceptions import InvalidURL In 0.12.0 the exception isn't caught:

Minimal Reproduction

repro.py
In [1]: import httpx ...: from httpx.exceptions import InvalidURL In [2]: try: ...: httpx.get("foo.bar") ...: except InvalidURL: ...: pass ...:

Environment

  • Python: 3.7
  • httpx: 0.11.1

What Broke

Users experienced uncaught exceptions when using the InvalidURL exception class.

Fix Options (Details)

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

Upgrade to version 0.13.0 or later.

When NOT to use: This fix should not be used if the application relies on the old module structure.

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

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

  • This fix should not be used if the application relies on the old module structure.

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.
  • Make timeouts explicit and test them (unit + integration) to avoid silent behavior changes.
  • Instrument retries (attempt count + reason) and alert on spikes to catch dependency slowdowns.

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.