The Fix
pip install pydantic==1.10.20
Based on closed pydantic/pydantic issue #11201 · 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%.
@@ -45,7 +45,7 @@ except ValidationError as e:
```
-1. See the [Extra Attributes](models.md#extra-fields) section for more details.
+1. See the [Extra data](models.md#extra-data) section for more details.
from typing import Any
from pydantic import ConfigDict, Field
from pydantic.dataclasses import dataclass
@dataclass
class Dataclass:
x: int
__pydantic_config__ = ConfigDict(extra="allow")
__pydantic_extra__: dict[str, Any] = Field(init=False)
d = Dataclass(x=1, y=2)
print(d.__pydantic_extra__)
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==1.10.20\nWhen NOT to use: This fix is not applicable if you require `__pydantic_extra__` for dataclasses.\n\n
Why This Fix Works in Production
- Trigger: pydantic.errors.PydanticUserError: Field __pydantic_extra__ has `init=False` and dataclass has config setting `extra="allow"`. This combination is not allowed.
- Mechanism: The combination of `__pydantic_config__` with `extra='allow'` and `__pydantic_extra__` with `init=False` is not supported in Pydantic dataclasses
- Why the fix works: Updated documentation to clarify that `__pydantic_extra__` is not supported for dataclasses and to provide insights on handling extra data. (first fixed release: 1.10.20).
- 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.11 in real deployments (not just unit tests).
- The combination of `__pydantic_config__` with `extra='allow'` and `__pydantic_extra__` with `init=False` is not supported in Pydantic dataclasses
- Surfaces as: pydantic.errors.PydanticUserError: Field __pydantic_extra__ has `init=False` and dataclass has config setting `extra="allow"`. This combination is not allowed.
Proof / Evidence
- GitHub issue: #11201
- Fix PR: https://github.com/pydantic/pydantic/pull/11213
- First fixed release: 1.10.20
- 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.64
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: 1.10.20
- Mode: fixed_only
- Outcome: ok
Logs
default=PydanticUndefined extra={'init': False}
\n\n[stderr]\n/tmp/ss-exec-tjk6_vht/repro.py:7: RuntimeWarning: fields may not start with an underscore, ignoring "__pydantic_extra__"
class Dataclass:
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“In the meantime I implement __pydantic_extra__ with a somewhat naive property:”
“I see, thank you :slightly_smiling_face:”
“__pydantic_extra__ is actually not supported for dataclasses”
Failure Signature (Search String)
- pydantic.errors.PydanticUserError: Field __pydantic_extra__ has `init=False` and dataclass has config setting `extra="allow"`. This combination is not allowed.
Error Message
Stack trace
Error Message
-------------
pydantic.errors.PydanticUserError: Field __pydantic_extra__ has `init=False` and dataclass has config setting `extra="allow"`. This combination is not allowed.
Stack trace
Error Message
-------------
AttributeError: 'Dataclass' object has no attribute '__pydantic_extra__'. Did you mean: '__pydantic_config__'?
Minimal Reproduction
from typing import Any
from pydantic import ConfigDict, Field
from pydantic.dataclasses import dataclass
@dataclass
class Dataclass:
x: int
__pydantic_config__ = ConfigDict(extra="allow")
__pydantic_extra__: dict[str, Any] = Field(init=False)
d = Dataclass(x=1, y=2)
print(d.__pydantic_extra__)
Environment
- Python: 3.11
- Pydantic: 2
What Broke
Users encounter errors when trying to use extra fields in Pydantic dataclasses.
Why It Broke
The combination of `__pydantic_config__` with `extra='allow'` and `__pydantic_extra__` with `init=False` is not supported in Pydantic dataclasses
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install pydantic==1.10.20
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/11213
First fixed release: 1.10.20
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- This fix is not applicable if you require `__pydantic_extra__` for dataclasses.
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 |
|---|---|
| 1.10.20 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.