The Fix
pip install pydantic==2.11.5
Based on closed pydantic/pydantic issue #11854 · 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%.
@@ -411,6 +411,9 @@ def rebuild_model_fields(
This function should be called whenever a model with incomplete fields is encountered.
+ Raises:
+ NameError: If one of the annotations failed to evaluate.
+
from typing import List
from pydantic import BaseModel
class C[T](BaseModel):
a: T
D = C[List['SomeType']]
D.model_rebuild(force=True, _types_namespace={'SomeType': int})
print(D.model_fields)
# In pydantic 2.9 it prints: {'a': FieldInfo(annotation=List[int], required=True)}
# But in 2.10 and 2.11 it does not work: {'a': FieldInfo(annotation=List[ForwardRef('SomeType')], required=True)}
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
Option A — Upgrade to fixed release\npip install pydantic==2.11.5\nWhen NOT to use: Do not use this fix if your application relies on the previous behavior of model_rebuild.\n\n
Why This Fix Works in Production
- Trigger: model_rebuild with _types_namespace does not update forward references in parameterized generic models after v2.10
- Mechanism: Fixes the issue where model_rebuild does not update forward references in parameterized generic models after v2.10.
- Why the fix works: Fixes the issue where model_rebuild does not update forward references in parameterized generic models after v2.10. (first fixed release: 2.11.5).
- 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): model_rebuild with _types_namespace does not update forward references in parameterized generic models after v2.10
Proof / Evidence
- GitHub issue: #11854
- Fix PR: https://github.com/pydantic/pydantic/pull/11855
- First fixed release: 2.11.5
- Reproduced locally: No (not executed)
- Last verified: 2026-02-09
- Confidence: 0.95
- 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).
“### Initial Checks - [x] I confirm that I'm using Pydantic V2 ### Description In 2.9, model_rebuild can update forward references in generic models. But in 2.10 and 2.11, it does not work as expected. ### Example Code ### Python, Pydantic &”
Failure Signature (Search String)
- model_rebuild with _types_namespace does not update forward references in parameterized generic models after v2.10
- In 2.9, model_rebuild can update forward references in generic models. But in 2.10 and 2.11, it does not work as expected.
Copy-friendly signature
Failure Signature
-----------------
model_rebuild with _types_namespace does not update forward references in parameterized generic models after v2.10
In 2.9, model_rebuild can update forward references in generic models. But in 2.10 and 2.11, it does not work as expected.
Error Message
Signature-only (no traceback captured)
Error Message
-------------
model_rebuild with _types_namespace does not update forward references in parameterized generic models after v2.10
In 2.9, model_rebuild can update forward references in generic models. But in 2.10 and 2.11, it does not work as expected.
Minimal Reproduction
from typing import List
from pydantic import BaseModel
class C[T](BaseModel):
a: T
D = C[List['SomeType']]
D.model_rebuild(force=True, _types_namespace={'SomeType': int})
print(D.model_fields)
# In pydantic 2.9 it prints: {'a': FieldInfo(annotation=List[int], required=True)}
# But in 2.10 and 2.11 it does not work: {'a': FieldInfo(annotation=List[ForwardRef('SomeType')], required=True)}
Environment
- Pydantic: 2
What Broke
Users experience incorrect model field annotations leading to runtime errors.
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install pydantic==2.11.5
Use when you can deploy the upstream fix. It is usually lower-risk than long-lived workarounds.
Fix reference: https://github.com/pydantic/pydantic/pull/11855
First fixed release: 2.11.5
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 previous behavior of model_rebuild.
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
- 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.11.5 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.