The Fix
pip install pydantic==1.10.19
Based on closed pydantic/pydantic issue #9414 · 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 Any, Generic, TypeVar
from pydantic import BaseModel, ValidationError
T = TypeVar("T")
class ResponseModel(BaseModel, Generic[T]):
content: T
class Product(BaseModel):
name: str
price: float
class Order(BaseModel):
id: int
product: ResponseModel[Any]
# replacing the previous annotation with the following succeeds at runtime but fails type checking
# product: ResponseModel
product = Product(name="Apple", price=0.5)
response1: ResponseModel[Any] = ResponseModel[Any](content=product)
response2: ResponseModel[Any] = ResponseModel(content=product)
response3: ResponseModel[Any] = ResponseModel[Product](content=product)
for response in response1, response2, response3:
try:
order = Order(id=1, product=response)
print(f"{response!r} succeeded")
except ValidationError:
print(f"{response!r} failed")
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: Do not use ResponseModel[Any] if you require strict type validation.\n\n
Why This Fix Works in Production
- Trigger: GenericModel[Any] raises ValidationError for GenericModel[SomeModel]
- Mechanism: Validation disallows instances of generic models that are not subclasses
- Why the fix works: Revalidates parametrized generics if an instance's origin is a subclass of the original class, addressing the validation issue with ResponseModel[Any]. (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
- Validation disallows instances of generic models that are not subclasses
- Surfaces as: GenericModel[Any] raises ValidationError for GenericModel[SomeModel]
Proof / Evidence
- GitHub issue: #9414
- 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.46
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.19
- Mode: fixed_only
- Outcome: ok
Logs
ResponseModel(content=Product(name='Apple', price=0.5)) succeeded
ResponseModel(content=Product(name='Apple', price=0.5)) succeeded
ResponseModel(content=Product(name='Apple', price=0.5)) succeeded
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“Hi @gsakkis, Thanks for your questions”
“So, the problem here is that we create concrete subclasses for each parametrization of a generic model, and model validation disallows instances of classes that…”
Failure Signature (Search String)
- GenericModel[Any] raises ValidationError for GenericModel[SomeModel]
Error Message
Stack trace
Error Message
-------------
GenericModel[Any] raises ValidationError for GenericModel[SomeModel]
Minimal Reproduction
from typing import Any, Generic, TypeVar
from pydantic import BaseModel, ValidationError
T = TypeVar("T")
class ResponseModel(BaseModel, Generic[T]):
content: T
class Product(BaseModel):
name: str
price: float
class Order(BaseModel):
id: int
product: ResponseModel[Any]
# replacing the previous annotation with the following succeeds at runtime but fails type checking
# product: ResponseModel
product = Product(name="Apple", price=0.5)
response1: ResponseModel[Any] = ResponseModel[Any](content=product)
response2: ResponseModel[Any] = ResponseModel(content=product)
response3: ResponseModel[Any] = ResponseModel[Product](content=product)
for response in response1, response2, response3:
try:
order = Order(id=1, product=response)
print(f"{response!r} succeeded")
except ValidationError:
print(f"{response!r} failed")
Environment
- Pydantic: 2
What Broke
Instances of ResponseModel[Any] fail to validate as expected, causing runtime errors.
Why It Broke
Validation disallows instances of generic models that are not subclasses
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
- Do not use ResponseModel[Any] if you require strict type validation.
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.