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%.
@@ -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)
from __future__ import annotations
from pydantic.dataclasses import dataclass
@dataclass
class Foo[T]:
value: T
print(Foo(value=1))
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.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).
- 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
- GitHub issue: #11031
- Fix PR: https://github.com/pydantic/pydantic/pull/11189
- First fixed release: 1.10.20
- 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.59
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:”
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 Message
-------------
pydantic.errors.PydanticUserError: `Foo` is not fully defined; you should define `T`, then call `pydantic.dataclasses.rebuild_dataclass(Foo)`.
Stack trace
Error Message
-------------
pydantic.errors.PydanticUserError: `Bar` is not fully defined; you should define `T`, then call `Bar.model_rebuild()`.
Minimal Reproduction
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
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.
When NOT to Use This Fix
- This fix should not be used if the application does not require PEP 695 support.
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.20 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.