The Fix
pip install pydantic==2.11.4
Based on closed pydantic/pydantic issue #12061 · 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%.
@@ -22,7 +22,7 @@
from ._config import ConfigWrapper
from ._decorators import DecoratorInfos, PydanticDescriptorProxy, get_attribute_from_bases, unwrap_wrapped_function
-from ._fields import collect_model_fields, is_valid_field_name, is_valid_privateattr_name
+from ._fields import collect_model_fields, is_valid_field_name, is_valid_privateattr_name, rebuild_model_fields
from ._generate_schema import GenerateSchema, InvalidSchemaError
from pydantic import BaseModel
class Core(BaseModel):
part: list['Part']
class Part(Core):
pass
# Still forward references
Core.model_fields["part"].annotation
#> list['Part']
Part.model_fields["part"].annotation
#> list['Part']
# Rebuild Core, forward reference resolved
Core.model_rebuild()
#> True
Core.model_fields["part"].annotation
#> list[__reprex__.Part]
# Rebuild Part, nothing happens, still unresolved
Part.model_rebuild()
Part.model_fields["part"].annotation
#> list['Part']
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.4\nWhen NOT to use: This fix should not be used if the model structure does not involve forward references.\n\n
Why This Fix Works in Production
- Trigger: Calling model_rebuild on the child class does not resolve forward references, leading to incorrect behavior.
- Mechanism: model_rebuild incorrectly determines that a rebuild is not required for forward references in Pydantic models
- Why the fix works: Fixes the issue where model_rebuild incorrectly determines that a rebuild is not required for forward references in Pydantic models. (first fixed release: 2.11.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
- model_rebuild incorrectly determines that a rebuild is not required for forward references in Pydantic models
- Production symptom (often without a traceback): Calling model_rebuild on the child class does not resolve forward references, leading to incorrect behavior.
Proof / Evidence
- GitHub issue: #12061
- Fix PR: https://github.com/pydantic/pydantic/pull/11759
- First fixed release: 2.11.4
- Reproduced locally: No (not executed)
- Last verified: 2026-02-09
- Confidence: 0.85
- Did this fix it?: Yes (upstream fix exists)
- Own content ratio: 0.55
Verified Execution
We executed the runnable minimal repro in a temporary environment and captured exit codes + logs.
- Status: PASS
- Ran: 2026-02-11T16:52:29Z
- Package: pydantic
- Fixed: 2.11.4
- Mode: fixed_only
- Outcome: ok
Logs
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“This was fixed by https://github.com/pydantic/pydantic/pull/11759, which will land in the 2.12 release.”
Failure Signature (Search String)
- Calling model_rebuild on the child class does not resolve forward references, leading to incorrect behavior.
Copy-friendly signature
Failure Signature
-----------------
Calling model_rebuild on the child class does not resolve forward references, leading to incorrect behavior.
Error Message
Signature-only (no traceback captured)
Error Message
-------------
Calling model_rebuild on the child class does not resolve forward references, leading to incorrect behavior.
Minimal Reproduction
from pydantic import BaseModel
class Core(BaseModel):
part: list['Part']
class Part(Core):
pass
# Still forward references
Core.model_fields["part"].annotation
#> list['Part']
Part.model_fields["part"].annotation
#> list['Part']
# Rebuild Core, forward reference resolved
Core.model_rebuild()
#> True
Core.model_fields["part"].annotation
#> list[__reprex__.Part]
# Rebuild Part, nothing happens, still unresolved
Part.model_rebuild()
Part.model_fields["part"].annotation
#> list['Part']
Environment
- Pydantic: 2
What Broke
Calling model_rebuild on the child class does not resolve forward references, leading to incorrect behavior.
Why It Broke
model_rebuild incorrectly determines that a rebuild is not required for forward references in Pydantic models
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install pydantic==2.11.4
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/11759
First fixed release: 2.11.4
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- This fix should not be used if the model structure does not involve forward references.
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.4 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.