The Fix
pip install pydantic==2.11.0
Based on closed pydantic/pydantic issue #11341 · 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%.
@@ -3,6 +3,7 @@
from collections.abc import Iterable
from copy import copy
+from decimal import Decimal
from functools import lru_cache, partial
from typing import TYPE_CHECKING, Any
from decimal import Decimal
from pydantic import BaseModel, Field
class Model(BaseModel):
other_amt: Decimal = Field(
decimal_places=1, multiple_of=0.5, le=2
)
m = Model(other_amt=Decimal("1.4"))
m_json = m.model_dump_json()
m_from_json = Model.model_validate_json(m_json)
#> TypeError: unsupported operand type(s) for /: 'decimal.Decimal' and 'float'
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.0\nWhen NOT to use: This fix is not applicable if decimal constraints should remain as floats.\n\n
Why This Fix Works in Production
- Trigger: SchemaError: Error building "model-fields" validator:
- Mechanism: Decimal constraints were not coerced to Decimal instances during schema validation
- Why the fix works: Coerces decimal constraints to `Decimal` instances, addressing issues with core schema validation being disabled. (first fixed release: 2.11.0).
- 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
- Decimal constraints were not coerced to Decimal instances during schema validation
- Surfaces as: SchemaError: Error building "model-fields" validator:
Proof / Evidence
- GitHub issue: #11341
- Fix PR: https://github.com/pydantic/pydantic/pull/11350
- First fixed release: 2.11.0
- Reproduced locally: No (not executed)
- Last verified: 2026-02-09
- Confidence: 0.85
- Did this fix it?: Yes (upstream fix exists)
- Own content ratio: 0.58
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“I went through all the core schemas types”
Failure Signature (Search String)
- SchemaError: Error building "model-fields" validator:
Error Message
Stack trace
Error Message
-------------
SchemaError: Error building "model-fields" validator:
SchemaError: Field "a":
SchemaError: Error building "int" validator:
TypeError: Expected int, got <class 'float'>
Minimal Reproduction
from decimal import Decimal
from pydantic import BaseModel, Field
class Model(BaseModel):
other_amt: Decimal = Field(
decimal_places=1, multiple_of=0.5, le=2
)
m = Model(other_amt=Decimal("1.4"))
m_json = m.model_dump_json()
m_from_json = Model.model_validate_json(m_json)
#> TypeError: unsupported operand type(s) for /: 'decimal.Decimal' and 'float'
What Broke
TypeError occurred when validating models with decimal constraints.
Why It Broke
Decimal constraints were not coerced to Decimal instances during schema validation
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install pydantic==2.11.0
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/11350
First fixed release: 2.11.0
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- This fix is not applicable if decimal constraints should remain as floats.
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.0 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.