The Fix
pip install pydantic==2.6.1
Based on closed pydantic/pydantic issue #8670 · 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%.
@@ -93,7 +93,7 @@ def dataclass(
@dataclass_transform(field_specifiers=(dataclasses.field, Field))
-def dataclass(
+def dataclass( # noqa: C901
_cls: type[_T] | None = None,
from pydantic import dataclasses
class A:
a: int = dataclasses.Field()
@dataclasses.dataclass()
class B(A):
...
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.6.1\nWhen NOT to use: This fix should not be applied if the base class is not decorated with Pydantic's dataclass.\n\nOption B — Safe version pin\npip install pydantic==2.5\nWhen NOT to use: Do not use if you need features or security fixes in newer releases.\n\n
Why This Fix Works in Production
- Trigger: class B(A):
- Mechanism: Inheritance issue with Pydantic dataclasses caused annotations to be lost when using Field in inherited classes
- Why the fix works: Fixes an inheritance issue with Pydantic dataclasses where annotations were lost when using Field in inherited classes. (first fixed release: 2.6.1).
- 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.8 in real deployments (not just unit tests).
- Inheritance issue with Pydantic dataclasses caused annotations to be lost when using Field in inherited classes
- Surfaces as: Traceback (most recent call last):
Proof / Evidence
- GitHub issue: #8670
- Fix PR: https://github.com/pydantic/pydantic/pull/8679
- First fixed release: 2.6.1
- Reproduced locally: No (not executed)
- Last verified: 2026-02-09
- Confidence: 0.75
- Did this fix it?: Yes (upstream fix exists)
- Own content ratio: 0.59
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.6.1
- Mode: fixed_only
- Outcome: ok
Logs
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“@mwalsh161, I've merged a PR with a fix for this issue (in the case of the decorated base class), and we'll include this in the…”
“The issue has been introduced in https://github.com/pydantic/pydantic/commit/2e459bb563dbc296c2bcffbfd1a3caf21241b8e0”
“Excellent point - that was a transcription error on my part (our actual use-case wraps both). That case will yield the same error (just reconfirmed…”
“@mwalsh161, Thanks for reporting this. We'll come up with a fix and hopefully get a patch release out tomorrow!”
Failure Signature (Search String)
- class B(A):
Error Message
Stack trace
Error Message
-------------
Traceback (most recent call last):
File "pydantic2.6.py", line 9, in <module>
class B(A):
File ".../pydantic/dataclasses.py", line 218, in create_dataclass
cls = dataclasses.dataclass( # type: ignore[call-overload]
File ".../dataclasses.py", line 1019, in dataclass
return wrap(cls)
File ".../dataclasses.py", line 1011, in wrap
return _process_class(cls, init, repr, eq, order, unsafe_hash, frozen)
File ".../dataclasses.py", line 885, in _process_class
raise TypeError(f'{name!r} is a field but has no type annotation')
TypeError: 'a' is a field but has no type annotation
Minimal Reproduction
from pydantic import dataclasses
class A:
a: int = dataclasses.Field()
@dataclasses.dataclass()
class B(A):
...
Environment
- Python: 3.8
- Pydantic: 2
What Broke
Users experienced TypeErrors when attempting to instantiate subclasses with inherited fields.
Why It Broke
Inheritance issue with Pydantic dataclasses caused annotations to be lost when using Field in inherited classes
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install pydantic==2.6.1
Use when you can deploy the upstream fix. It is usually lower-risk than long-lived workarounds.
Option B — Safe version pin Backward-compatible pin
pip install pydantic==2.5
Use when you can’t upgrade immediately. Plan a follow-up to upgrade (pins can accumulate security/compat debt).
Fix reference: https://github.com/pydantic/pydantic/pull/8679
First fixed release: 2.6.1
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- This fix should not be applied if the base class is not decorated with Pydantic's dataclass.
- Do not use if you need features or security fixes in newer releases.
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.5 | Working |
| 2.6.1 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.