Jump to solution
Verify

The Fix

pip install pydantic==2.11.6

Based on closed pydantic/pydantic issue #11920 · PR/commit linked

Jump to Verify Open PR/Commit
@@ -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):
repro.py
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'})}
verify
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
fix.md
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).
Production impact:
  • 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

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”
Issue thread · issue description · source

Failure Signature (Search String)

  • a: T = Field(alias='_a', json_schema_extra={"key": "value"})
Copy-friendly signature
signature.txt
Failure Signature ----------------- a: T = Field(alias='_a', json_schema_extra={"key": "value"})

Error Message

Signature-only (no traceback captured)
error.txt
Error Message ------------- a: T = Field(alias='_a', json_schema_extra={"key": "value"})

Minimal Reproduction

repro.py
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

When NOT to use: Do not apply this fix if the model does not require preserving field info during rebuild.

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.

Get updates

We publish verified fixes weekly. No spam.

Subscribe

When NOT to Use This Fix

  • Do not apply this fix if the model does not require preserving field info during rebuild.

Verify Fix

verify
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

VersionStatus
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.