Jump to solution
Verify

The Fix

pip install pydantic==1.10.19

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

Jump to Verify Open PR/Commit
@@ -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
repro.py
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")
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.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).
Production impact:
  • 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

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
affected (exit=None)
fixed (exit=0)
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”
@sydney-runkle · 2024-05-16 · source
“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…”
@dmontagu · 2024-05-30 · source

Failure Signature (Search String)

  • GenericModel[Any] raises ValidationError for GenericModel[SomeModel]

Error Message

Stack trace
error.txt
Error Message ------------- GenericModel[Any] raises ValidationError for GenericModel[SomeModel]

Minimal Reproduction

repro.py
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

When NOT to use: Do not use ResponseModel[Any] if you require strict type validation.

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.

Get updates

We publish verified fixes weekly. No spam.

Subscribe

When NOT to Use This Fix

  • Do not use ResponseModel[Any] if you require strict type validation.

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

Related Issues

No related fixes found.

Sources

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