The Fix
pip install pydantic==2.11.6
Based on closed pydantic/pydantic issue #11920 · PR/commit linked
@@ -334,12 +334,13 @@ def collect_model_fields( # noqa: C901
field_info = FieldInfo_.from_annotated_attribute(ann_type, assigned_value, _source=AnnotationSource.CLASS)
+ # Store the original annotation and assignment value that should be used to rebuild the field info later.
+ # Note that the assignment is always stored as the annotation might contain a type var that is later
+ # parameterized with an unknown forward reference (and we'll need it to rebuild the field info):
from typing import List
from pydantic import BaseModel, Field
class C[T](BaseModel):
a: T = Field(alias='_a', json_schema_extra={"key": "value"})
D = C[List['SomeType']]
D.model_rebuild(force=True, _types_namespace={'SomeType': int})
print(D.model_fields)
# in v2.11.5 it prints {'a': FieldInfo(annotation=List[int], required=True)}
# while in v2.9.2 it prints {'a': FieldInfo(annotation=List[int], required=True, alias='_a', alias_priority=2, json_schema_extra={'key': 'value'})}
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.6\nWhen NOT to use: Do not apply this fix if the model does not require preserving field info during rebuild.\n\n
Why This Fix Works in Production
- Trigger: a: T = Field(alias='_a', json_schema_extra={"key": "value"})
- Mechanism: FieldInfo attributes are not preserved during model rebuild due to missing original assignment storage
- Why the fix works: Ensures that the original field assignment is stored on `FieldInfo`, addressing the issue where field infos are lost after model rebuild. (first fixed release: 2.11.6).
- If left unfixed, this can cause silent data inconsistencies that propagate (bad cache entries, incorrect downstream decisions).
Why This Breaks in Prod
- FieldInfo attributes are not preserved during model rebuild due to missing original assignment storage
- Production symptom (often without a traceback): a: T = Field(alias='_a', json_schema_extra={"key": "value"})
Proof / Evidence
- GitHub issue: #11920
- Fix PR: https://github.com/pydantic/pydantic/pull/11946
- First fixed release: 2.11.6
- 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.53
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“### Initial Checks - [x] I confirm that I'm using Pydantic V2 ### Description After upgrading to v2.11.5, field infos like alias and json_schem_extra will be lost after applying the model_rebuild method on a generic model. In v2.9.2 it work”
Failure Signature (Search String)
- a: T = Field(alias='_a', json_schema_extra={"key": "value"})
Copy-friendly signature
Failure Signature
-----------------
a: T = Field(alias='_a', json_schema_extra={"key": "value"})
Error Message
Signature-only (no traceback captured)
Error Message
-------------
a: T = Field(alias='_a', json_schema_extra={"key": "value"})
Minimal Reproduction
from typing import List
from pydantic import BaseModel, Field
class C[T](BaseModel):
a: T = Field(alias='_a', json_schema_extra={"key": "value"})
D = C[List['SomeType']]
D.model_rebuild(force=True, _types_namespace={'SomeType': int})
print(D.model_fields)
# in v2.11.5 it prints {'a': FieldInfo(annotation=List[int], required=True)}
# while in v2.9.2 it prints {'a': FieldInfo(annotation=List[int], required=True, alias='_a', alias_priority=2, json_schema_extra={'key': 'value'})}
Environment
- Pydantic: 2
What Broke
Field information like alias and json_schema_extra is lost, leading to incorrect model behavior.
Why It Broke
FieldInfo attributes are not preserved during model rebuild due to missing original assignment storage
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install pydantic==2.11.6
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/11946
First fixed release: 2.11.6
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- Do not apply this fix if the model does not require preserving field info during 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.6 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.