Jump to solution
Verify

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

Jump to Verify Open PR/Commit
@@ -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. +
repro.py
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)}
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.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).
Production impact:
  • 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

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

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
signature.txt
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.txt
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

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

When NOT to use: Do not use this fix if your application relies on the previous behavior of model_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/11855

First fixed release: 2.11.5

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 use this fix if your application relies on the previous behavior of model_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.5 Fixed

Related Issues

No related fixes found.

Sources

We don’t republish the full GitHub discussion text. Use the links above for context.