The Fix
pip install pydantic==2.11.8
Based on closed pydantic/pydantic issue #12045 · 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%.
@@ -2,10 +2,15 @@
from __future__ import annotations as _annotations
+import copy
+import dataclasses
+import sys
# Stdlib dataclasses
from dataclasses import dataclass, field
class BareClass:
a: int
b: int = field(kw_only=True)
@dataclass
class DC(BareClass):
pass
# As documented in https://docs.python.org/3/library/dataclasses.html#inheritance:
list(DC.__dataclass_fields__.keys())
# []
# Pydantic dataclasses
from pydantic.dataclasses import dataclass
from pydantic import Field
class BareClass:
a: int
# This time using Pydantic's Field():
b: int = Field(kw_only=True)
@dataclass
class DC(BareClass):
pass
list(DC.__dataclass_fields__.keys())
#> ['b']
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==2.11.8\nWhen NOT to use: Do not apply this fix if using non-Pydantic dataclasses without Field().\n\n
Why This Fix Works in Production
- Trigger: Users experienced incorrect field types in Pydantic dataclasses, leading to runtime errors.
- Mechanism: Inconsistencies in handling Pydantic's Field() function in dataclasses caused unexpected behavior
- Why the fix works: Refactor logic to support Pydantic's `Field()` function in dataclasses, addressing inconsistencies in dataclass field handling. (first fixed release: 2.11.8).
- 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
- Inconsistencies in handling Pydantic's Field() function in dataclasses caused unexpected behavior
- Production symptom (often without a traceback): Users experienced incorrect field types in Pydantic dataclasses, leading to runtime errors.
Proof / Evidence
- GitHub issue: #12045
- Fix PR: https://github.com/pydantic/pydantic/pull/12051
- First fixed release: 2.11.8
- 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.60
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: 2.11.8
- Mode: fixed_only
- Outcome: ok
Logs
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“First issue: Second issue:”
Failure Signature (Search String)
- Users experienced incorrect field types in Pydantic dataclasses, leading to runtime errors.
Copy-friendly signature
Failure Signature
-----------------
Users experienced incorrect field types in Pydantic dataclasses, leading to runtime errors.
Error Message
Signature-only (no traceback captured)
Error Message
-------------
Users experienced incorrect field types in Pydantic dataclasses, leading to runtime errors.
Minimal Reproduction
# Stdlib dataclasses
from dataclasses import dataclass, field
class BareClass:
a: int
b: int = field(kw_only=True)
@dataclass
class DC(BareClass):
pass
# As documented in https://docs.python.org/3/library/dataclasses.html#inheritance:
list(DC.__dataclass_fields__.keys())
# []
# Pydantic dataclasses
from pydantic.dataclasses import dataclass
from pydantic import Field
class BareClass:
a: int
# This time using Pydantic's Field():
b: int = Field(kw_only=True)
@dataclass
class DC(BareClass):
pass
list(DC.__dataclass_fields__.keys())
#> ['b']
What Broke
Users experienced incorrect field types in Pydantic dataclasses, leading to runtime errors.
Why It Broke
Inconsistencies in handling Pydantic's Field() function in dataclasses caused unexpected behavior
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install pydantic==2.11.8
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/12051
First fixed release: 2.11.8
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- Do not apply this fix if using non-Pydantic dataclasses without Field().
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 |
|---|---|
| 2.11.8 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.