The Fix
pip install pydantic==2.7.2
Based on closed pydantic/pydantic issue #9383 · 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%.
@@ -1117,4 +1117,22 @@ except PydanticUserError as exc_info:
```
+## `dataclass` is used on a `BaseModel` subclass {#dataclass-on-model}
+
+This error is raised when the Pydantic `dataclass` decorator is used on a class which is already
from pydantic import BaseModel
from pydantic.dataclasses import dataclass
@dataclass
class Foo(BaseModel):
a: int
Foo(a=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==2.7.2\nWhen NOT to use: This fix does not apply if the class is intended to be a dataclass without extending BaseModel.\n\n
Why This Fix Works in Production
- Trigger: pydantic_core._pydantic_core.ValidationError: 1 validation error for Foo
- Mechanism: The error occurs when a class extends BaseModel and uses the @dataclass decorator simultaneously
- Why the fix works: Raises an error when the Pydantic `dataclass` decorator is used on a class that extends `BaseModel`, addressing the misleading error message. (first fixed release: 2.7.2).
- 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
- The error occurs when a class extends BaseModel and uses the @dataclass decorator simultaneously
- Surfaces as: pydantic_core._pydantic_core.ValidationError: 1 validation error for Foo
Proof / Evidence
- GitHub issue: #9383
- Fix PR: https://github.com/pydantic/pydantic/pull/9388
- First fixed release: 2.7.2
- 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.65
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“I getting simillar error message can some one please help me here Pydantic - Version: 2.9.2 Error message : Exception occured : 3 validation errors…”
Failure Signature (Search String)
- pydantic_core._pydantic_core.ValidationError: 1 validation error for Foo
Error Message
Stack trace
Error Message
-------------
pydantic_core._pydantic_core.ValidationError: 1 validation error for Foo
Input should be a valid dictionary or instance of Foo [type=model_type, input_value=ArgsKwargs((), {'a': 1}), input_type=ArgsKwargs]
For further information visit https://errors.pydantic.dev/2.7/v/model_type
Minimal Reproduction
from pydantic import BaseModel
from pydantic.dataclasses import dataclass
@dataclass
class Foo(BaseModel):
a: int
Foo(a=1)
Environment
- Pydantic: 2
What Broke
Users encounter misleading validation errors when instantiating models incorrectly combining BaseModel and dataclass.
Why It Broke
The error occurs when a class extends BaseModel and uses the @dataclass decorator simultaneously
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install pydantic==2.7.2
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/9388
First fixed release: 2.7.2
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- This fix does not apply if the class is intended to be a dataclass without extending BaseModel.
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.7.2 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.