Jump to solution
Verify

The Fix

pip install pydantic==2.10.3

Based on closed pydantic/pydantic issue #10953 · 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
@@ -125,6 +125,8 @@ def __init__(__dataclass_self__: PydanticDataclass, *args: Any, **kwargs: Any) - cls.__pydantic_config__ = config_wrapper.config_dict # type: ignore + set_dataclass_fields(cls, ns_resolver, config_wrapper=config_wrapper) + if not _force_build and config_wrapper.defer_build:
repro.py
import typing import pydantic @pydantic.dataclasses.dataclass(kw_only=True, config=pydantic.config.ConfigDict(defer_build=True)) class MyObject: msg_id: str receipt_handle: str @pydantic.validate_call def do_work(input: MyObject|typing.Iterable[MyObject]|list[MyObject]): pass
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.10.3\nWhen NOT to use: This fix should not be applied if defer_build is not used.\n\n

Why This Fix Works in Production

  • Trigger: Data class with defer_build set to true causes the error AttributeError: type object '...' has no attribute '__pydantic_fields__'. Did you mean:…
  • Mechanism: The error occurs due to missing field initialization when defer_build is set to true
  • Why the fix works: Sets fields when `defer_build` is set on Pydantic dataclasses, aligning with Pydantic models where only the schema generation is deferred. (first fixed release: 2.10.3).
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 due to missing field initialization when defer_build is set to true
  • Surfaces as: Data class with defer_build set to true causes the error AttributeError: type object '...' has no attribute '__pydantic_fields__'. Did you mean: '__pydantic_config__'

Proof / Evidence

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.10.3
  • Mode: fixed_only
  • Outcome: ok
Logs
affected (exit=None)
fixed (exit=0)

Discussion

High-signal excerpts from the issue thread (symptoms, repros, edge-cases).

“### Initial Checks - [X] I confirm that I'm using Pydantic V2 ### Description Upgraded from 2.9.2 and the below code wll now fail unless I set **defer_build** to false ### Example Code ### Python, Pydantic & OS Version”
Issue thread · issue description · source

Failure Signature (Search String)

  • Data class with defer_build set to true causes the error AttributeError: type object '...' has no attribute '__pydantic_fields__'. Did you mean: '__pydantic_config__'

Error Message

Stack trace
error.txt
Error Message ------------- Data class with defer_build set to true causes the error AttributeError: type object '...' has no attribute '__pydantic_fields__'. Did you mean: '__pydantic_config__'

Minimal Reproduction

repro.py
import typing import pydantic @pydantic.dataclasses.dataclass(kw_only=True, config=pydantic.config.ConfigDict(defer_build=True)) class MyObject: msg_id: str receipt_handle: str @pydantic.validate_call def do_work(input: MyObject|typing.Iterable[MyObject]|list[MyObject]): pass

Environment

  • Pydantic: 2

What Broke

Users experience AttributeError when using Pydantic dataclasses with defer_build set to true.

Why It Broke

The error occurs due to missing field initialization when defer_build is set to true

Fix Options (Details)

Option A — Upgrade to fixed release Safe default (recommended)

pip install pydantic==2.10.3

When NOT to use: This fix should not be applied if defer_build is not used.

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/10984

First fixed release: 2.10.3

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 should not be applied if defer_build is not used.

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

Related Issues

No related fixes found.

Sources

We don’t republish the full GitHub discussion text. Use the links above for context.