The Fix
pip install pydantic==1.10.1
Based on closed pydantic/pydantic issue #9165 · PR/commit linked
@@ -61,6 +61,7 @@
'TimeError',
'DurationError',
+ 'HashableError',
'UUIDError',
'UUIDVersionError',
import pydantic
class TestModel(pydantic.BaseModel):
a: int
b: int | None = None
TestModel(**{'b': '000001', 'a': '1'})
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.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).
- 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
- GitHub issue: #9165
- Fix PR: https://github.com/pydantic/pydantic-core/pull/1266
- First fixed release: 1.10.1
- 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.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: 1.10.1
- Mode: fixed_only
- Outcome: ok
Logs
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.”
“@hlloreda, Thanks for reporting this. We're looking into this issue and will work on a fix before we release 2.7!”
Failure Signature (Search String)
- TestModel(**{'b': '000001', 'a': '1'})
Error Message
Stack trace
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
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
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.
When NOT to Use This Fix
- This fix should not be applied if integer parsing is not required.
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.1 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.