The Fix
pip install urllib3==2.1.0
Based on closed urllib3/urllib3 issue #3174 · 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.
@@ -0,0 +1 @@
@@ -0,0 +1 @@
+Fixed decoding Gzip-encoded responses which specified ``x-gzip`` content-encoding.
diff --git a/src/urllib3/response.py b/src/urllib3/response.py
index 367ccfe425..37936f9397 100644
Option A — Upgrade to fixed release\npip install urllib3==2.1.0\nWhen NOT to use: Do not use this fix if you require strict adherence to content encoding standards without exceptions.\n\n
Why This Fix Works in Production
- Trigger: I'm using an API that returns a gzipped response, but the reported `Content-Encoding` is `x-gzip` rather than `gzip`, so urllib3 fails to decompress it.
- Mechanism: urllib3 fails to decompress responses with 'x-gzip' content encoding due to lack of handling
- Why the fix works: Treats 'x-gzip' content encoding as equivalent to 'gzip', allowing urllib3 to decompress responses correctly. (first fixed release: 2.1.0).
- 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
- urllib3 fails to decompress responses with 'x-gzip' content encoding due to lack of handling
- Production symptom (often without a traceback): I'm using an API that returns a gzipped response, but the reported `Content-Encoding` is `x-gzip` rather than `gzip`, so urllib3 fails to decompress it.
Proof / Evidence
- GitHub issue: #3174
- Fix PR: https://github.com/urllib3/urllib3/pull/3176
- First fixed release: 2.1.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.71
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“https://github.com/urllib3/urllib3/blob/7d0648b53cf4159e7f3ebb8353cb642942ec93e6/src/urllib3/response.py#L207-L220 could be trivially updated to say, after we get past the MultiDecoder return do a if mode.startswith("x-"):\n\t\tmode = mode[2:] and then we don'”
“FWIW, I don't think it's a good idea to blindly assume that x-foo is the same as foo, since there is no guarantee that will…”
“@jeremycline has submitted a PR for this issue.”
Failure Signature (Search String)
- I'm using an API that returns a gzipped response, but the reported `Content-Encoding` is `x-gzip` rather than `gzip`, so urllib3 fails to decompress it.
- Unfortunately, I can't find a public server that would produce such responses, so I can't provide a simple reproducer.
Copy-friendly signature
Failure Signature
-----------------
I'm using an API that returns a gzipped response, but the reported `Content-Encoding` is `x-gzip` rather than `gzip`, so urllib3 fails to decompress it.
Unfortunately, I can't find a public server that would produce such responses, so I can't provide a simple reproducer.
Error Message
Signature-only (no traceback captured)
Error Message
-------------
I'm using an API that returns a gzipped response, but the reported `Content-Encoding` is `x-gzip` rather than `gzip`, so urllib3 fails to decompress it.
Unfortunately, I can't find a public server that would produce such responses, so I can't provide a simple reproducer.
What Broke
Responses with 'x-gzip' content encoding are not decompressed, leading to incorrect data handling.
Why It Broke
urllib3 fails to decompress responses with 'x-gzip' content encoding due to lack of handling
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install urllib3==2.1.0
Use when you can deploy the upstream fix. It is usually lower-risk than long-lived workarounds.
Fix reference: https://github.com/urllib3/urllib3/pull/3176
First fixed release: 2.1.0
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- Do not use this fix if you require strict adherence to content encoding standards without exceptions.
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 |
|---|---|
| 2.1.0 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.