The Fix
pip install pydantic==2.10.4
Based on closed pydantic/pydantic issue #11708 · 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%.
@@ -1122,14 +1122,14 @@ assert error.model_dump() == {
There are some occasions where it is desirable to create a model using runtime information to specify the fields.
-For this Pydantic provides the `create_model` function to allow models to be created on the fly:
+Pydantic provides the [`create_model()`][pydantic.create_model] function to allow models to be created dynamically:
from pydantic import BaseModel, computed_field, create_model
def area(self) -> float:
return self.length**2
Square = create_model(
"Square",
__base__=BaseModel,
length=(float, "length"),
area=computed_field(area),
)
print(Square(length=2).model_dump())
# For pydantic < 2.11, Output: {'length': 2.0, 'area': 4.0}
# For pydantic >= 2.11, raises AttributeError: 'property' object has no attribute '__mro__'
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.10.4\nWhen NOT to use: Do not use if it changes public behavior or if the failure cannot be reproduced.\n\n
Why This Fix Works in Production
- Trigger: AttributeError when using `create_model` with `computed_field`.
- Mechanism: Reworked the `create_model` field definitions format to allow computed fields to be specified correctly, fixing an AttributeError in Pydantic 2.11 and later.
- Why the fix works: Reworked the `create_model` field definitions format to allow computed fields to be specified correctly, fixing an AttributeError in Pydantic 2.11 and later. (first fixed release: 2.10.4).
- 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).
- Surfaces as: AttributeError when using `create_model` with `computed_field`.
Proof / Evidence
- GitHub issue: #11708
- Fix PR: https://github.com/pydantic/pydantic/pull/11032
- First fixed release: 2.10.4
- 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.55
Verified Execution
We executed the runnable minimal repro in a temporary environment and captured exit codes + logs.
- Status: PASS
- Ran: 2026-02-11T16:52:29Z
- Package: pydantic
- Fixed: 2.10.4
- Mode: fixed_only
- Outcome: ok
Logs
{'length': 2.0, 'area': 4.0}
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“It seems that passing computed fields as normal fields in create_model() was accidentally working before 2.11, but this wasn't documented nor intended”
Failure Signature (Search String)
- AttributeError when using `create_model` with `computed_field`.
Error Message
Stack trace
Error Message
-------------
AttributeError when using `create_model` with `computed_field`.
Minimal Reproduction
from pydantic import BaseModel, computed_field, create_model
def area(self) -> float:
return self.length**2
Square = create_model(
"Square",
__base__=BaseModel,
length=(float, "length"),
area=computed_field(area),
)
print(Square(length=2).model_dump())
# For pydantic < 2.11, Output: {'length': 2.0, 'area': 4.0}
# For pydantic >= 2.11, raises AttributeError: 'property' object has no attribute '__mro__'
Environment
- Python: 3.12
- Pydantic: 2
What Broke
Using `create_model` with computed fields results in an AttributeError, breaking model creation.
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install pydantic==2.10.4
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/11032
First fixed release: 2.10.4
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- Do not use if it changes public behavior or if the failure cannot be reproduced.
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.10.4 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.