Jump to solution
Verify

The Fix

Upgrade to version 0.24.1 or later.

Based on closed encode/httpx issue #2670 · 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
@@ -399,7 +399,7 @@ def normalize_path(path: str) -> str: def percent_encode(char: str) -> str: """ - Replace every character in a string with the percent-encoded representation. + Replace a single character with the percent-encoded representation.
repro.py
from urllib.parse importparse_qs from httpx._urls import urlencode parse_qs( urlencode((('u', "http://example.com?q=foo%2Fa%20b%2Ac"),))) # -> {'u': ['http://example.com?q=foo/a b*c']} # Incorrect url decoded from the query string from urllib.parse import urlencode parse_qs( urlencode((('u', "http://example.com?q=foo%2Fa%20b%2Ac"),))) # -> {'u': ['http://example.com?q=foo%2Fa%20b%2Ac']} # Correct original url decoded from the query string
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.24.1 or later.\nWhen NOT to use: This fix should not be applied if the application relies on the previous encoding behavior.\n\n

Why This Fix Works in Production

  • Trigger: Since httpx 0.24 the behavior regarding query params changed, and possibly contains a bug.
  • Mechanism: Fixes the optional percent encoding behavior in query parameters, ensuring that pre-signed URLs are correctly encoded.
  • Why the fix works: Fixes the optional percent encoding behavior in query parameters, ensuring that pre-signed URLs are correctly encoded. (first fixed release: 0.24.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

  • Production symptom (often without a traceback): Since httpx 0.24 the behavior regarding query params changed, and possibly contains a bug.

Proof / Evidence

  • GitHub issue: #2670
  • Fix PR: https://github.com/encode/httpx/pull/2671
  • First fixed release: 0.24.1
  • 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.54

Discussion

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

“If understand correctly, the new code still leaves query parameters which look like already percent-escapes as-is? I think this is not a good idea, because…”
@dlange-hima · 2023-04-19 · source
“This is related to the changes here: https://github.com/encode/httpx/pull/2543”
@rslinckx · 2023-04-19 · source
“Also for forward-slashes https://github.com/encode/httpx/discussions/2661”
@marban · 2023-04-19 · source
“+1 for @dlange-hima I belive that urlparse(urlencode(x)) shoud be equal to x. This won't be true for parameter values like %20. With current solution it's…”
@peku33 · 2023-05-04 · source

Failure Signature (Search String)

  • Since httpx 0.24 the behavior regarding query params changed, and possibly contains a bug.
  • This is related to the changes here: https://github.com/encode/httpx/pull/2543
Copy-friendly signature
signature.txt
Failure Signature ----------------- Since httpx 0.24 the behavior regarding query params changed, and possibly contains a bug. This is related to the changes here: https://github.com/encode/httpx/pull/2543

Error Message

Signature-only (no traceback captured)
error.txt
Error Message ------------- Since httpx 0.24 the behavior regarding query params changed, and possibly contains a bug. This is related to the changes here: https://github.com/encode/httpx/pull/2543

Minimal Reproduction

repro.py
from urllib.parse importparse_qs from httpx._urls import urlencode parse_qs( urlencode((('u', "http://example.com?q=foo%2Fa%20b%2Ac"),))) # -> {'u': ['http://example.com?q=foo/a b*c']} # Incorrect url decoded from the query string from urllib.parse import urlencode parse_qs( urlencode((('u', "http://example.com?q=foo%2Fa%20b%2Ac"),))) # -> {'u': ['http://example.com?q=foo%2Fa%20b%2Ac']} # Correct original url decoded from the query string

Environment

  • httpx: 0.24

What Broke

Query parameters containing percent-escaped sequences were not encoded correctly, leading to incorrect URL handling.

Fix Options (Details)

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

Upgrade to version 0.24.1 or later.

When NOT to use: This fix should not be applied if the application relies on the previous encoding behavior.

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

First fixed release: 0.24.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 applied if the application relies on the previous encoding behavior.

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

Related Issues

No related fixes found.

Sources

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