Jump to solution
Verify

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%.

Jump to Verify Open PR/Commit
@@ -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
repro.py
from pydantic import BaseModel from pydantic.dataclasses import dataclass @dataclass class Foo(BaseModel): a: int Foo(a=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==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).
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

  • 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

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…”
@Nikhila-Akuluru · 2024-10-17 · source

Failure Signature (Search String)

  • pydantic_core._pydantic_core.ValidationError: 1 validation error for Foo

Error Message

Stack trace
error.txt
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

repro.py
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

When NOT to use: This fix does not apply if the class is intended to be a dataclass without extending BaseModel.

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.

Get updates

We publish verified fixes weekly. No spam.

Subscribe

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

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