Jump to solution
Verify

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

Jump to Verify Open PR/Commit
@@ -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
repro.py
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"
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==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).
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

  • 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

Discussion

High-signal excerpts from the issue thread (symptoms, repros, edge-cases).

“Hi @olivierdolle, Thanks for your question”
@sydney-runkle · 2024-09-16 · source

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

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

When NOT to use: Do not use this fix if you need strict type validation for strings.

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.

Get updates

We publish verified fixes weekly. No spam.

Subscribe

When NOT to Use This Fix

  • Do not use this fix if you need strict type validation for strings.

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