The Fix
pip install pydantic==1.10.1
Based on closed pydantic/pydantic issue #8835 · PR/commit linked
@@ -0,0 +1 @@
@@ -0,0 +1 @@
+fix mypy signature for `root_validator`
diff --git a/pydantic/class_validators.py b/pydantic/class_validators.py
index 19f2924ccfa..3d1032e789e 100644
import pydantic
def test_validate_json_large_integer():
class IntModel(pydantic.BaseModel):
my_dict: dict[int, str]
large_integer = 1433352099889938534014333520998899385340
r = IntModel(my_dict={large_integer: ""})
s = r.model_dump_json()
assert IntModel.model_validate_json(s).my_dict == {large_integer: ""}
assert (
IntModel.model_validate_json(
'{"my_dict":{"' + str(large_integer) + '":""}}'
).my_dict
== large_integer
)
def test_validate_json_large_integer_direct():
class IntModel(pydantic.BaseModel):
my_dict: dict[int, str]
large_integer = 1433352099889938534014333520998899385340
assert (
IntModel.model_validate_json(
'{"my_dict":{"' + str(large_integer) + '":""}}'
).my_dict
== large_integer
)
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: Do not use this fix if your application relies on the previous behavior of handling large integers differently.\n\n
Why This Fix Works in Production
- Trigger: import pydantic
- Mechanism: Deserialization fails for large integers used as dictionary keys in Pydantic models
- Why the fix works: Fixed a bug where large integers as dict keys failed to parse from JSON in Pydantic models. (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).
- Deserialization fails for large integers used as dictionary keys in Pydantic models
- Surfaces as: import pydantic
Proof / Evidence
- GitHub issue: #8835
- Fix PR: https://github.com/pydantic/pydantic-core/pull/1204
- First fixed release: 1.10.1
- Reproduced locally: No (not executed)
- Last verified: 2026-02-09
- Confidence: 0.95
- Did this fix it?: Yes (upstream fix exists)
- Own content ratio: 0.37
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“Fixed in pydantic-core, will be released with 2.7.0!”
“I have to admit this bug was principally uncovered by using hypothesis. It is very good at turning up evil test cases I would never…”
“@td-anne, Good catch! This is definitely a bug”
Failure Signature (Search String)
- import pydantic
Error Message
Stack trace
Error Message
-------------
import pydantic
large_integer = 1433352099889938534014333520998899385340
class IntModel(pydantic.BaseModel):
my_int: int
assert IntModel.model_validate_json('{"my_int":"' + str(large_integer) + '"}').my_int == large_integer
class IntModel(pydantic.BaseModel):
my_dict: dict[int, str]
r = IntModel(my_dict={large_integer: ""})
s = r.model_dump_json()
print(s)
#> {"my_dict":{"1433352099889938534014333520998899385340":""}}
print(IntModel.model_validate_json(s))
"""
pydantic_core._pydantic_core.ValidationError: 1 validation error for IntModel
my_dict.1433352099889938534014333520998899385340.[key]
Input should be a valid integer, unable to parse string as an integer [type=int_parsing, input_value='1433352099889938534014333520998899385340', input_type=str]
For further information visit https://errors.pydantic.dev/2.7/v/int_parsing
"""
Minimal Reproduction
import pydantic
def test_validate_json_large_integer():
class IntModel(pydantic.BaseModel):
my_dict: dict[int, str]
large_integer = 1433352099889938534014333520998899385340
r = IntModel(my_dict={large_integer: ""})
s = r.model_dump_json()
assert IntModel.model_validate_json(s).my_dict == {large_integer: ""}
assert (
IntModel.model_validate_json(
'{"my_dict":{"' + str(large_integer) + '":""}}'
).my_dict
== large_integer
)
def test_validate_json_large_integer_direct():
class IntModel(pydantic.BaseModel):
my_dict: dict[int, str]
large_integer = 1433352099889938534014333520998899385340
assert (
IntModel.model_validate_json(
'{"my_dict":{"' + str(large_integer) + '":""}}'
).my_dict
== large_integer
)
Environment
- Python: 3.11
- Pydantic: 2
What Broke
Deserialization errors occur when large integers are used as dictionary keys, causing application failures.
Why It Broke
Deserialization fails for large integers used as dictionary keys in Pydantic models
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/1204
First fixed release: 1.10.1
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- Do not use this fix if your application relies on the previous behavior of handling large integers differently.
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.