The Fix
pip install pydantic==2.11.2
Based on closed pydantic/pydantic issue #11663 · 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%.
@@ -202,24 +202,23 @@ def collect_model_fields( # noqa: C901
if assigned_value is PydanticUndefined: # no assignment, just a plain annotation
- if ann_name in annotations:
- # field is present in the current model's annotations (and *not* from parent classes)
+ if ann_name in annotations or ann_name not in parent_fields_lookup:
from typing import List
from pydantic import BaseModel
from child import Child
class Parent(BaseModel):
children: List[Child] = []
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.2\nWhen NOT to use: Do not apply this fix if your model does not use forward references.\n\n
Why This Fix Works in Production
- Trigger: parent.py:
- Mechanism: Field annotations are not resolved correctly in inherited classes when using forward references
- Why the fix works: Addresses a regression that caused issues with forward references in inherited classes, ensuring that field annotations are resolved correctly. (first fixed release: 2.11.2).
- 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
- Field annotations are not resolved correctly in inherited classes when using forward references
- Surfaces as: parent.py:
Proof / Evidence
- GitHub issue: #11663
- Fix PR: https://github.com/pydantic/pydantic/pull/11668
- First fixed release: 2.11.2
- 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.45
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“Update, the requirement for implicit imports goes away if I remove from __future__ import annotations import from the child class - but the validation issue…”
“Thanks for the bug report, this will be addressed in the next patch release.”
Failure Signature (Search String)
- parent.py:
Error Message
Stack trace
Error Message
-------------
parent.py:
----------
from typing import List
from pydantic import BaseModel
from child import Child
class Parent(BaseModel):
children: List[Child] = []
child.py:
---------
from __future__ import annotations
from typing import TYPE_CHECKING, List, Optional
from pydantic import BaseModel
if TYPE_CHECKING:
from parent import Parent
class Child(BaseModel):
name: str = "test"
parents: Optional[List["Parent"]] = None
main.py:
--------
from parent import Parent
from child import Child
Child.model_rebuild()
class ExtendedChild(Child):
name: str = "MyB"
b = ExtendedChild()
output:
-------
...
pydantic.errors.PydanticUserError: `ExtendedChild` is not fully defined; you should define `Optional`, then call `ExtendedChild.model_rebuild()`.
Minimal Reproduction
from typing import List
from pydantic import BaseModel
from child import Child
class Parent(BaseModel):
children: List[Child] = []
Environment
- Pydantic: 2
What Broke
Validation errors occur due to missing default values in inherited classes.
Why It Broke
Field annotations are not resolved correctly in inherited classes when using forward references
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install pydantic==2.11.2
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/11668
First fixed release: 2.11.2
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- Do not apply this fix if your model does not use 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.2 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.