Jump to solution
Verify

The Fix

pip install pydantic==1.10.1

Based on closed pydantic/pydantic issue #9165 · PR/commit linked

Jump to Verify Open PR/Commit
@@ -61,6 +61,7 @@ 'TimeError', 'DurationError', + 'HashableError', 'UUIDError', 'UUIDVersionError',
repro.py
import pydantic class TestModel(pydantic.BaseModel): a: int b: int | None = None TestModel(**{'b': '000001', 'a': '1'})
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.1\nWhen NOT to use: This fix should not be applied if integer parsing is not required.\n\n

Why This Fix Works in Production

  • Trigger: TestModel(**{'b': '000001', 'a': '1'})
  • Mechanism: Parsing a string as an integer fails due to validation error in Pydantic
  • Why the fix works: Fixes an issue where parsing a string as an integer would fail in Pydantic. (first fixed release: 1.10.1).
Production impact:
  • If left unfixed, this can cause silent data inconsistencies that propagate (bad cache entries, incorrect downstream decisions).

Why This Breaks in Prod

  • Shows up under Python 3.11 in real deployments (not just unit tests).
  • Parsing a string as an integer fails due to validation error in Pydantic
  • Surfaces as: Traceback (most recent call last):

Proof / Evidence

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: 1.10.1
  • Mode: fixed_only
  • Outcome: ok
Logs
affected (exit=None)
fixed (exit=0)

Discussion

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

“Thanks for reporting @hlloreda, this is a really good catch. This is fixed in https://github.com/pydantic/pydantic-core/pull/1266.”
@samuelcolvin · 2024-04-06 · confirmation · source
“@hlloreda, Thanks for reporting this. We're looking into this issue and will work on a fix before we release 2.7!”
@sydney-runkle · 2024-04-04 · source

Failure Signature (Search String)

  • TestModel(**{'b': '000001', 'a': '1'})

Error Message

Stack trace
error.txt
Error Message ------------- Traceback (most recent call last): File "/home/hugo/PycharmProjects/pythonProject3/main.py", line 9, in <module> TestModel(**{'b': '000001', 'a': '1'}) File "/home/hugo/PycharmProjects/pythonProject3/venv/lib/python3.11/site-packages/pydantic/main.py", line 175, in __init__ self.__pydantic_validator__.validate_python(data, self_instance=self) pydantic_core._pydantic_core.ValidationError: 1 validation error for TestModel b Input should be a valid integer, unable to parse string as an integer [type=int_parsing, input_value='000001', input_type=str] For further information visit https://errors.pydantic.dev/2.7/v/int_parsing

Minimal Reproduction

repro.py
import pydantic class TestModel(pydantic.BaseModel): a: int b: int | None = None TestModel(**{'b': '000001', 'a': '1'})

Environment

  • Python: 3.11
  • Pydantic: 2

What Broke

Users encounter validation errors when passing string representations of integers.

Why It Broke

Parsing a string as an integer fails due to validation error in Pydantic

Fix Options (Details)

Option A — Upgrade to fixed release Safe default (recommended)

pip install pydantic==1.10.1

When NOT to use: This fix should not be applied if integer parsing is not required.

Use when you can deploy the upstream fix. It is usually lower-risk than long-lived workarounds.

Fix reference: https://github.com/pydantic/pydantic-core/pull/1266

First fixed release: 1.10.1

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

  • This fix should not be applied if integer parsing is not required.

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

Related Issues

No related fixes found.

Sources

We don’t republish the full GitHub discussion text. Use the links above for context.