The Fix
pip install pydantic==1.10.19
Based on closed pydantic/pydantic issue #10359 · PR/commit linked
@@ -772,12 +772,6 @@ Order(id=1, product=ResponseModel[Product](content=Product(name='Apple', price=0
```
-!!! tip
- When using a parametrized generic model as a type in another model (like `product: ResponseModel[Product]`),
- make sure to parametrize said generic model when you initialize the model instance
from typing import Generic, TypeVar
from pydantic import BaseModel
# Library side:
M = TypeVar("M", bound=BaseModel)
class InnerModel(BaseModel, Generic[M]):
model: M
I = TypeVar("I", bound=InnerModel)
class OuterModel(BaseModel, Generic[I]):
inner: I
# User side:
class MyModel(BaseModel):
foo: int
# Construct two instances, with and without generic annotation in the constructor:
inner1 = InnerModel[MyModel](model=MyModel(foo=42))
inner2 = InnerModel(model=MyModel(foo=42))
# Everything suggests the two are exactly the same, even the `__eq__` assertion passes:
print(inner1) # -> model=MyModel(foo=42)
print(inner2) # -> model=MyModel(foo=42)
assert inner1 == inner2
# However, one of them fails to validate within the outer model!
outer1 = OuterModel[InnerModel[MyModel]](inner=inner1) # works
outer2 = OuterModel[InnerModel[MyModel]](inner=inner2) # fails!
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.19\nWhen NOT to use: Avoid using unparametrized generics in model initialization to prevent validation issues.\n\n
Why This Fix Works in Production
- Trigger: In [1]: from typing import Any, TypeVar, Generic
- Mechanism: False positive validation errors occur due to unparametrized generic models in nested structures
- Why the fix works: Revalidates parametrized generics if an instance's origin is a subclass of the original class, addressing the issue of false positive validation errors in nested generic BaseModels. (first fixed release: 1.10.19).
- 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.10 in real deployments (not just unit tests).
- False positive validation errors occur due to unparametrized generic models in nested structures
- Surfaces as: In [1]: from typing import Any, TypeVar, Generic
Proof / Evidence
- GitHub issue: #10359
- Fix PR: https://github.com/pydantic/pydantic/pull/10666
- First fixed release: 1.10.19
- 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.36
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“> We might consider changing the current behavior to match static type checkers semantics, @sydney-runkle wdyt? Yes, I think this is reasonable”
“I believe this is currently expected”
“> Pydantic will default to Any, meaning Model(a=1) is equivalent to ModelAny Just to clarify: In the original example InnerModel(...) is actually not the same…”
Failure Signature (Search String)
- In [1]: from typing import Any, TypeVar, Generic
Error Message
Stack trace
Error Message
-------------
In [1]: from typing import Any, TypeVar, Generic
In [2]: from pydantic import BaseModel
In [3]: T = TypeVar("T", bound=int)
In [4]: class Model(BaseModel, Generic[T]):
...: x: T
...:
In [5]: Model[Any](x="not_an_int")
Out[5]: Model[Any](x='not_an_int')
In [6]: Model(x="not_an_int")
---------------------------------------------------------------------------
ValidationError Traceback (most recent call last)
Cell In[6], line 1
----> 1 Model(x="not_an_int")
File ~/git/immoscrape/venv/lib/python3.10/site-packages/pydantic/main.py:193, in BaseModel.__init__(self, **data)
191 # `__tracebackhide__` tells pytest and some other tools to omit this function from tracebacks
192 __tracebackhide__ = True
--> 193 self.__pydantic_validator__.validate_python(data, self_instance=self)
ValidationError: 1 validation error for Model
x
Input should be a valid integer, unable to parse string as an integer [type=int_parsing, input_value='not_an_int', input_type=str]
For further information visit https://errors.pydantic.dev/2.8/v/int_parsing
Minimal Reproduction
from typing import Generic, TypeVar
from pydantic import BaseModel
# Library side:
M = TypeVar("M", bound=BaseModel)
class InnerModel(BaseModel, Generic[M]):
model: M
I = TypeVar("I", bound=InnerModel)
class OuterModel(BaseModel, Generic[I]):
inner: I
# User side:
class MyModel(BaseModel):
foo: int
# Construct two instances, with and without generic annotation in the constructor:
inner1 = InnerModel[MyModel](model=MyModel(foo=42))
inner2 = InnerModel(model=MyModel(foo=42))
# Everything suggests the two are exactly the same, even the `__eq__` assertion passes:
print(inner1) # -> model=MyModel(foo=42)
print(inner2) # -> model=MyModel(foo=42)
assert inner1 == inner2
# However, one of them fails to validate within the outer model!
outer1 = OuterModel[InnerModel[MyModel]](inner=inner1) # works
outer2 = OuterModel[InnerModel[MyModel]](inner=inner2) # fails!
Environment
- Python: 3.10
- Pydantic: 2
What Broke
Users experience runtime crashes due to unexpected ValidationErrors in nested generic BaseModels.
Why It Broke
False positive validation errors occur due to unparametrized generic models in nested structures
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install pydantic==1.10.19
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/10666
First fixed release: 1.10.19
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- Avoid using unparametrized generics in model initialization to prevent validation issues.
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.19 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.