The Fix
pip install fastapi==0.128.4
Based on closed fastapi/fastapi issue #14484 · 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%.
@@ -209,11 +209,21 @@ def get_flat_params(dependant: Dependant) -> List[ModelField]:
-def get_typed_signature(call: Callable[..., Any]) -> inspect.Signature:
+def _get_signature(call: Callable[..., Any]) -> inspect.Signature:
if sys.version_info >= (3, 10):
# /// script
# requires-python = "==3.14.*"
# dependencies = [
# "fastapi==0.123.7",
# "uvicorn",
# ]
# ///
from __future__ import annotations
from typing import TYPE_CHECKING, Annotated
from fastapi import Depends, FastAPI
if TYPE_CHECKING:
from collections.abc import AsyncGenerator
app = FastAPI()
class DummyClient:
async def get_people(self) -> list:
return ["John Doe", "Jane Doe"]
async def close(self) -> None: ...
async def get_client() -> AsyncGenerator[DummyClient, None]:
client = DummyClient()
yield client
await client.close()
Client = Annotated[DummyClient, Depends(get_client)]
@app.get("/")
async def get_people(client: Client) -> list:
return await client.get_people()
if __name__ == "__main__":
import uvicorn
uvicorn.run(app, host="0.0.0.0", port=8000)
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.128.4\nWhen NOT to use: Do not use if it changes public behavior or if the failure cannot be reproduced.\n\n
Why This Fix Works in Production
- Trigger: In FastAPI 0.123.7, annotations from code imported in `if TYPE_CHECKING` could break
- Mechanism: Annotations from code imported in `if TYPE_CHECKING` were not handled correctly in FastAPI
- Why the fix works: Fix support for `if TYPE_CHECKING` and non-evaluated stringified annotations in FastAPI. (first fixed release: 0.128.4).
- 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
- Annotations from code imported in `if TYPE_CHECKING` were not handled correctly in FastAPI
- Production symptom (often without a traceback): In FastAPI 0.123.7, annotations from code imported in `if TYPE_CHECKING` could break
Proof / Evidence
- GitHub issue: #14484
- Fix PR: https://github.com/fastapi/fastapi/pull/14485
- First fixed release: 0.128.4
- Reproduced locally: No (not executed)
- Last verified: 2026-02-08
- Confidence: 0.85
- Did this fix it?: Yes (upstream fix exists)
- Own content ratio: 0.47
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“This is fixed by https://github.com/fastapi/fastapi/pull/14485, available in FastAPI 0.124.2, just released. 🎉”
Failure Signature (Search String)
- In FastAPI 0.123.7, annotations from code imported in `if TYPE_CHECKING` could break
Copy-friendly signature
Failure Signature
-----------------
In FastAPI 0.123.7, annotations from code imported in `if TYPE_CHECKING` could break
Error Message
Signature-only (no traceback captured)
Error Message
-------------
In FastAPI 0.123.7, annotations from code imported in `if TYPE_CHECKING` could break
Minimal Reproduction
# /// script
# requires-python = "==3.14.*"
# dependencies = [
# "fastapi==0.123.7",
# "uvicorn",
# ]
# ///
from __future__ import annotations
from typing import TYPE_CHECKING, Annotated
from fastapi import Depends, FastAPI
if TYPE_CHECKING:
from collections.abc import AsyncGenerator
app = FastAPI()
class DummyClient:
async def get_people(self) -> list:
return ["John Doe", "Jane Doe"]
async def close(self) -> None: ...
async def get_client() -> AsyncGenerator[DummyClient, None]:
client = DummyClient()
yield client
await client.close()
Client = Annotated[DummyClient, Depends(get_client)]
@app.get("/")
async def get_people(client: Client) -> list:
return await client.get_people()
if __name__ == "__main__":
import uvicorn
uvicorn.run(app, host="0.0.0.0", port=8000)
What Broke
Users experienced issues with type annotations leading to runtime errors.
Why It Broke
Annotations from code imported in `if TYPE_CHECKING` were not handled correctly in FastAPI
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install fastapi==0.128.4
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/14485
First fixed release: 0.128.4
Last verified: 2026-02-08. Validate in your environment.
When NOT to Use This Fix
- Do not use if it changes public behavior or if the failure cannot be reproduced.
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.128.4 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.