The Fix
pip install pydantic==2.11.3
Based on closed pydantic/pydantic issue #11696 · 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%.
@@ -319,6 +319,7 @@ def rebuild_model_fields(
rebuilt_fields[f_name] = field_info
else:
+ existing_desc = field_info.description
ann = _typing_extra.eval_type(
field_info._original_annotation,
from __future__ import annotations
from pydantic import BaseModel
class Model1(BaseModel, use_attribute_docstrings=True):
b: Model2
"""doc1"""
class Model2(BaseModel, use_attribute_docstrings=True):
pass
print(Model1.model_fields)
Model1.model_rebuild()
print(Model1.model_fields)
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.3\nWhen NOT to use: This fix should not be applied if the model does not use forward references.\n\n
Why This Fix Works in Production
- Trigger: model_rebuild() doesn't respect use_attribute_docstrings
- Mechanism: The rebuild_model_fields() method overwrites existing FieldInfo, losing descriptions from docstrings
- Why the fix works: Preserves the field description when rebuilding model fields, addressing a regression that caused descriptions to be lost with forward references. (first fixed release: 2.11.3).
- 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
- Shows up under Python 3.12 in real deployments (not just unit tests).
- The rebuild_model_fields() method overwrites existing FieldInfo, losing descriptions from docstrings
- Production symptom (often without a traceback): model_rebuild() doesn't respect use_attribute_docstrings
Proof / Evidence
- GitHub issue: #11696
- Fix PR: https://github.com/pydantic/pydantic/pull/11698
- First fixed release: 2.11.3
- 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.65
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“### Initial Checks - [x] I confirm that I'm using Pydantic V2 ### Description I'm writing a script to generate documentation for Pydantic classes. I'm using use_attribute_docstrings and have noticed that the docstring description gets lost”
Failure Signature (Search String)
- model_rebuild() doesn't respect use_attribute_docstrings
- Note the missing description in the second line.
Copy-friendly signature
Failure Signature
-----------------
model_rebuild() doesn't respect use_attribute_docstrings
Note the missing description in the second line.
Error Message
Signature-only (no traceback captured)
Error Message
-------------
model_rebuild() doesn't respect use_attribute_docstrings
Note the missing description in the second line.
Minimal Reproduction
from __future__ import annotations
from pydantic import BaseModel
class Model1(BaseModel, use_attribute_docstrings=True):
b: Model2
"""doc1"""
class Model2(BaseModel, use_attribute_docstrings=True):
pass
print(Model1.model_fields)
Model1.model_rebuild()
print(Model1.model_fields)
Environment
- Python: 3.12
- Pydantic: 2
What Broke
Model documentation generation fails to include field descriptions when using forward references.
Why It Broke
The rebuild_model_fields() method overwrites existing FieldInfo, losing descriptions from docstrings
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install pydantic==2.11.3
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/11698
First fixed release: 2.11.3
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- This fix should not be applied if the 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.3 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.