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%.
@@ -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:
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
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.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).
- 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
- GitHub issue: #10953
- Fix PR: https://github.com/pydantic/pydantic/pull/10984
- First fixed release: 2.10.3
- 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.10.3
- Mode: fixed_only
- Outcome: ok
Logs
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”
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 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
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
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.
When NOT to Use This Fix
- This fix should not be applied if defer_build is not used.
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.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.