The Fix
pip install pydantic==1.10.18
Based on closed pydantic/pydantic issue #10413 · 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%.
@@ -12,6 +12,7 @@
from contextlib import ExitStack, contextmanager
from copy import copy, deepcopy
+from decimal import Decimal
from enum import Enum
from functools import partial
from decimal import Decimal
from pydantic import BaseModel
class Cover(BaseModel):
deductible: Decimal | str
cover = Cover.model_validate({"deductible": "0"})
assert isinstance(cover.deductible, Decimal) # evaluates to "False"
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==1.10.18\nWhen NOT to use: Do not use this fix if you need strict type validation for strings.\n\n
Why This Fix Works in Production
- Trigger: I have observed a change in behavior confirmed in 2.9.0 and 2.9.1 compared to 2.8.2.
- Mechanism: Moves the validation for decimal.Decimal to a different part of the codebase, which affects how Decimal and str types are parsed in Pydantic.
- Why the fix works: Moves the validation for decimal.Decimal to a different part of the codebase, which affects how Decimal and str types are parsed in Pydantic. (first fixed release: 1.10.18).
- 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).
- Production symptom (often without a traceback): I have observed a change in behavior confirmed in 2.9.0 and 2.9.1 compared to 2.8.2.
Proof / Evidence
- GitHub issue: #10413
- Fix PR: https://github.com/pydantic/pydantic/pull/9977
- First fixed release: 1.10.18
- 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.63
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“Hi @olivierdolle, Thanks for your question”
Failure Signature (Search String)
- I have observed a change in behavior confirmed in 2.9.0 and 2.9.1 compared to 2.8.2.
- In 2.9.0 and 2.9.1, it does not try to parse to Decimal, or at least it always parses to str if the input is a string.
Copy-friendly signature
Failure Signature
-----------------
I have observed a change in behavior confirmed in 2.9.0 and 2.9.1 compared to 2.8.2.
In 2.9.0 and 2.9.1, it does not try to parse to Decimal, or at least it always parses to str if the input is a string.
Error Message
Signature-only (no traceback captured)
Error Message
-------------
I have observed a change in behavior confirmed in 2.9.0 and 2.9.1 compared to 2.8.2.
In 2.9.0 and 2.9.1, it does not try to parse to Decimal, or at least it always parses to str if the input is a string.
Minimal Reproduction
from decimal import Decimal
from pydantic import BaseModel
class Cover(BaseModel):
deductible: Decimal | str
cover = Cover.model_validate({"deductible": "0"})
assert isinstance(cover.deductible, Decimal) # evaluates to "False"
Environment
- Python: 3.12
- Pydantic: 2
What Broke
Incorrect type parsing leads to unexpected validation results in production applications.
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install pydantic==1.10.18
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/9977
First fixed release: 1.10.18
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- Do not use this fix if you need strict type validation for strings.
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 |
|---|---|
| 1.10.18 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.