Jump to solution
Verify

The Fix

pip install fastapi==0.99.0

Based on closed fastapi/fastapi issue #5646 · 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
@@ -39,7 +39,7 @@ classifiers = [ ] dependencies = [ - "starlette==0.21.0", + "starlette==0.22.0", "pydantic >=1.6.2,!=1.7,!=1.7.1,!=1.7.2,!=1.7.3,!=1.8,!=1.8.1,<2.0.0",
repro.py
import logging from fastapi import FastAPI app = FastAPI() @app.get("/example") async def _show_encoding_error(look_for: str): return {"found": look_for} if __name__ == '__main__': from fastapi.testclient import TestClient with TestClient(app) as client: params = {"look_for": "plain text"} resp = client.get("/example", params=params).json() logging.warning(resp) assert resp["found"] == "plain text" params = {"look_for": "España"} resp = client.get("/example", params=params).json() logging.warning(resp) assert resp["found"] == "España", resp["found"]
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\npip install fastapi==0.99.0\nWhen NOT to use: Do not use this fix if your application relies on the behavior of the previous Starlette version.\n\n

Why This Fix Works in Production

  • Trigger: async def _show_encoding_error(look_for: str):
  • Mechanism: The TestClient in FastAPI was using an outdated version of Starlette that caused encoding issues
  • Why the fix works: Bump Starlette to version 0.22.0 to fix bad encoding for query parameters in TestClient. (first fixed release: 0.99.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.10.5 in real deployments (not just unit tests).
  • The TestClient in FastAPI was using an outdated version of Starlette that caused encoding issues
  • Production symptom (often without a traceback): async def _show_encoding_error(look_for: str):

Proof / Evidence

  • GitHub issue: #5646
  • Fix PR: https://github.com/fastapi/fastapi/pull/5659
  • First fixed release: 0.99.0
  • Reproduced locally: No (not executed)
  • Last verified: 2026-02-09
  • Confidence: 0.70
  • Did this fix it?: Yes (upstream fix exists)
  • Own content ratio: 0.56

Discussion

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

“I just saw **this it is not related to FastAPI but to Starlette** 😅, after https://github.com/encode/starlette/pull/1376, and the example code above fails the same way…”
@azogue · 2022-11-15 · confirmation · source
“Thanks @azogue for reporting and upgrading it here! :cake: Thanks everyone for the discussion too! :coffee: This is available in FastAPI 0.88.0, just released. :rocket:”
@tiangolo · 2022-11-27 · confirmation · source
“For those in a hurry, or just to quick-check that the _strange broken tests_ you're having after the TestClient change to httpx are related to…”
@azogue · 2022-11-16 · source
“@Kludex What is the plan to fix it in FastAPI? Is there a PR that pulls in the Starlette 0.22.0? The Starlette 0.22.0 is already…”
@mezhaka · 2022-11-18 · source

Failure Signature (Search String)

  • async def _show_encoding_error(look_for: str):
  • assert resp["found"] == "plain text"
Copy-friendly signature
signature.txt
Failure Signature ----------------- async def _show_encoding_error(look_for: str): assert resp["found"] == "plain text"

Error Message

Signature-only (no traceback captured)
error.txt
Error Message ------------- async def _show_encoding_error(look_for: str): assert resp["found"] == "plain text"

Minimal Reproduction

repro.py
import logging from fastapi import FastAPI app = FastAPI() @app.get("/example") async def _show_encoding_error(look_for: str): return {"found": look_for} if __name__ == '__main__': from fastapi.testclient import TestClient with TestClient(app) as client: params = {"look_for": "plain text"} resp = client.get("/example", params=params).json() logging.warning(resp) assert resp["found"] == "plain text" params = {"look_for": "España"} resp = client.get("/example", params=params).json() logging.warning(resp) assert resp["found"] == "España", resp["found"]

Environment

  • Python: 3.10.5

What Broke

Query parameters with special characters were corrupted when received in endpoints.

Why It Broke

The TestClient in FastAPI was using an outdated version of Starlette that caused encoding issues

Fix Options (Details)

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

pip install fastapi==0.99.0

When NOT to use: Do not use this fix if your application relies on the behavior of the previous Starlette version.

Use when you can deploy the upstream fix. It is usually lower-risk than long-lived workarounds.

Fix reference: https://github.com/fastapi/fastapi/pull/5659

First fixed release: 0.99.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 this fix if your application relies on the behavior of the previous Starlette version.

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

  • Capture the exact failing error string in logs and tests so you can reproduce via a minimal script.
  • Pin production dependencies and upgrade only with a reproducible test that hits the failing path.

Version Compatibility Table

VersionStatus
0.99.0 Fixed

Related Issues

No related fixes found.

Sources

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