The Fix
Implements RFC 3986 compliant URL parsing in urllib3, addressing issues with path-only URLs and improving overall URL handling.
Based on closed urllib3/urllib3 issue #1096 · 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%.
@@ -4,7 +4,9 @@ Changes
------------
-* Implemented a more efficient ``HTTPResponse.__iter__()`` method (Issue #1483)
+* Implemented a more efficient ``HTTPResponse.__iter__()`` method. (Issue #1483)
+
Option A — Apply the official fix\nImplements RFC 3986 compliant URL parsing in urllib3, addressing issues with path-only URLs and improving overall URL handling.\nWhen NOT to use: This fix is not suitable if backward compatibility with existing URL parsing behavior is required.\n\n
Why This Fix Works in Production
- Trigger: Currently, `parse_url` doesn't do well with non-urlencoded URLs that are intended to have no host portion, as frequently used by HTTP Location headers:
- Mechanism: The parse_url function incorrectly assumes a scheme is present in path-only URLs, leading to parsing errors
- 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
- The parse_url function incorrectly assumes a scheme is present in path-only URLs, leading to parsing errors
- Production symptom (often without a traceback): Currently, `parse_url` doesn't do well with non-urlencoded URLs that are intended to have no host portion, as frequently used by HTTP Location headers:
Proof / Evidence
- GitHub issue: #1096
- Fix PR: https://github.com/urllib3/urllib3/pull/1487
- Reproduced locally: No (not executed)
- Last verified: 2026-02-12
- Confidence: 0.80
- Did this fix it?: Yes (upstream fix exists)
- Own content ratio: 0.72
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“I certainly have no problem with swapping to a more robust implementation. If you're open to making a patch against the v2 branch that swaps…”
“The reason urlparse handles this correctly is also the reason why rfc3986 gets it right: Our API is just slightly incompatible with the way parse_url…”
Failure Signature (Search String)
- Currently, `parse_url` doesn't do well with non-urlencoded URLs that are intended to have no host portion, as frequently used by HTTP Location headers:
- The larger issue doesn't block v2, but this does. It's probably something that @sigmavirus24 could give guidance on if someone wants to pick it up.
Copy-friendly signature
Failure Signature
-----------------
Currently, `parse_url` doesn't do well with non-urlencoded URLs that are intended to have no host portion, as frequently used by HTTP Location headers:
The larger issue doesn't block v2, but this does. It's probably something that @sigmavirus24 could give guidance on if someone wants to pick it up.
Error Message
Signature-only (no traceback captured)
Error Message
-------------
Currently, `parse_url` doesn't do well with non-urlencoded URLs that are intended to have no host portion, as frequently used by HTTP Location headers:
The larger issue doesn't block v2, but this does. It's probably something that @sigmavirus24 could give guidance on if someone wants to pick it up.
What Broke
Incorrect URL parsing causes backend failures in handling HTTP Location headers, leading to potential request failures.
Why It Broke
The parse_url function incorrectly assumes a scheme is present in path-only URLs, leading to parsing errors
Fix Options (Details)
Option A — Apply the official fix
Implements RFC 3986 compliant URL parsing in urllib3, addressing issues with path-only URLs and improving overall URL handling.
Fix reference: https://github.com/urllib3/urllib3/pull/1487
Last verified: 2026-02-12. Validate in your environment.
When NOT to Use This Fix
- This fix is not suitable if backward compatibility with existing URL parsing behavior is required.
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.
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.