Jump to solution
Verify

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

Jump to Verify Open PR/Commit
@@ -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.
repro.py
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__)
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==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).
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

  • 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

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
affected (exit=None)
fixed (exit=0)
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:”
@pawamoy · 2024-12-31 · source
“I see, thank you :slightly_smiling_face:”
@pawamoy · 2025-01-03 · source
“__pydantic_extra__ is actually not supported for dataclasses”
@Viicos · 2025-01-03 · source

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.txt
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.txt
Error Message ------------- AttributeError: 'Dataclass' object has no attribute '__pydantic_extra__'. Did you mean: '__pydantic_config__'?

Minimal Reproduction

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

When NOT to use: This fix is not applicable if you require `__pydantic_extra__` for dataclasses.

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.

Get updates

We publish verified fixes weekly. No spam.

Subscribe

When NOT to Use This Fix

  • This fix is not applicable if you require `__pydantic_extra__` for dataclasses.

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