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%.
@@ -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",
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"]
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
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).
- 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…”
“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:”
“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…”
“@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…”
Failure Signature (Search String)
- async def _show_encoding_error(look_for: str):
- assert resp["found"] == "plain text"
Copy-friendly signature
Failure Signature
-----------------
async def _show_encoding_error(look_for: str):
assert resp["found"] == "plain text"
Error Message
Signature-only (no traceback captured)
Error Message
-------------
async def _show_encoding_error(look_for: str):
assert resp["found"] == "plain text"
Minimal Reproduction
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
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.
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
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
| Version | Status |
|---|---|
| 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.