Jump to solution
Verify

The Fix

pip install pydantic==1.10.20

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

Production note: Most teams hit this during upgrades or environment changes. Roll out with a canary and smoke critical endpoints (health, OpenAPI/docs) before 100%.

Jump to Verify Open PR/Commit
@@ -648,62 +648,96 @@ Here are some additional notes on the behavior of [`model_construct()`][pydantic ## Generic models -Pydantic supports the creation of generic models to make it easier to reuse a common model structure. +Pydantic supports the creation of generic models to make it easier to reuse a common model structure. Both the new +[type parameter syntax][type-params] (introduced by [PEP 695](https://peps.python.org/pep-0695/) in Python 3.12)
repro.py
from __future__ import annotations from pydantic.dataclasses import dataclass @dataclass class Foo[T]: value: T print(Foo(value=1))
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.20\nWhen NOT to use: This fix should not be used if the application does not require PEP 695 support.\n\n

Why This Fix Works in Production

  • Trigger: pydantic.errors.PydanticUserError: `Foo` is not fully defined; you should define `T`, then call `pydantic.dataclasses.rebuild_dataclass(Foo)`.
  • Mechanism: The error occurs due to improper handling of PEP 695 generics syntax in dataclasses
  • Why the fix works: Properly supports PEP 695 generics syntax, fixing the issue where the error occurs when using the new generic syntax with dataclasses. (first fixed release: 1.10.20).
Production impact:
  • If left unfixed, the same config can fail only in production (env differences), causing startup failures or partial feature outages.

Why This Breaks in Prod

  • Shows up under Python 3.12 in real deployments (not just unit tests).
  • The error occurs due to improper handling of PEP 695 generics syntax in dataclasses
  • Surfaces as: pydantic.errors.PydanticUserError: `Foo` is not fully defined; you should define `T`, then call `pydantic.dataclasses.rebuild_dataclass(Foo)`.

Proof / Evidence

Discussion

High-signal excerpts from the issue thread (symptoms, repros, edge-cases).

“also happens when a regular dataclass is used as an arbitrary type with a BaseModel:”
@DetachHead · 2024-12-03 · source

Failure Signature (Search String)

  • pydantic.errors.PydanticUserError: `Foo` is not fully defined; you should define `T`, then call `pydantic.dataclasses.rebuild_dataclass(Foo)`.

Error Message

Stack trace
error.txt
Error Message ------------- pydantic.errors.PydanticUserError: `Foo` is not fully defined; you should define `T`, then call `pydantic.dataclasses.rebuild_dataclass(Foo)`.
Stack trace
error.txt
Error Message ------------- pydantic.errors.PydanticUserError: `Bar` is not fully defined; you should define `T`, then call `Bar.model_rebuild()`.

Minimal Reproduction

repro.py
from __future__ import annotations from pydantic.dataclasses import dataclass @dataclass class Foo[T]: value: T print(Foo(value=1))

Environment

  • Python: 3.12
  • Pydantic: 2

What Broke

Users encounter a PydanticUserError when using new generic syntax with dataclasses.

Why It Broke

The error occurs due to improper handling of PEP 695 generics syntax in dataclasses

Fix Options (Details)

Option A — Upgrade to fixed release Safe default (recommended)

pip install pydantic==1.10.20

When NOT to use: This fix should not be used if the application does not require PEP 695 support.

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/11189

First fixed release: 1.10.20

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

  • This fix should not be used if the application does not require PEP 695 support.

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

Related Issues

No related fixes found.

Sources

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