Jump to solution
Verify

The Fix

pip install pydantic==1.10.18

Based on closed pydantic/pydantic issue #10041 · 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
@@ -1840,6 +1840,9 @@ def _dataclass_schema( config=core_config, metadata=metadata, + # we don't use a custom __setattr__ for dataclasses, so we must + # pass along the frozen config setting to the pydantic-core schema + frozen=self._config_wrapper_stack.tail.frozen,
repro.py
def test_cannot_validate_assignment_when_frozen(): @pydantic.dataclasses.dataclass(config=ConfigDict(validate_assignment=True), frozen=True) class MyDataclass: a: int d = MyDataclass(2) assert d.a == 2 with pytest.raises(ValidationError) as exc_info: d.a = 3 assert exc_info.value.errors(include_url=False) == [ { 'type': 'frozen_instance', 'loc': ('a',), 'msg': 'Instance is frozen', 'input': '3', } ]
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.18\nWhen NOT to use: Do not use this fix if you require mutable fields in frozen dataclasses.\n\n

Why This Fix Works in Production

  • Trigger: validate_assignment breaks frozen for dataclasses
  • Mechanism: The frozen setting was not properly enforced for dataclasses with validate_assignment enabled
  • Why the fix works: Fixes the issue where frozen dataclasses with validate_assignment enabled were allowing field mutations. (first fixed release: 1.10.18).
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 frozen setting was not properly enforced for dataclasses with validate_assignment enabled
  • Production symptom (often without a traceback): validate_assignment breaks frozen for dataclasses

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

Discussion

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

“Great work. This is interesting - we don't actually set frozen on model schemas generally bc we enforce things with a custom __setattr__ which we…”
@sydney-runkle · 2024-08-06 · source
“@czlr, Good find, definitely a bug. Help with a fix is welcome!”
@sydney-runkle · 2024-08-05 · source
“Hi @sydney-runkle, everybody, I took some time to see if I could have helped with this”
@AlessandroMiola · 2024-08-06 · source

Failure Signature (Search String)

  • validate_assignment breaks frozen for dataclasses
  • - While it arguably doesn't make sense for both settings to be used together, it would be a nasty surprise if these are coming from defaults
Copy-friendly signature
signature.txt
Failure Signature ----------------- validate_assignment breaks frozen for dataclasses - While it arguably doesn't make sense for both settings to be used together, it would be a nasty surprise if these are coming from defaults

Error Message

Signature-only (no traceback captured)
error.txt
Error Message ------------- validate_assignment breaks frozen for dataclasses - While it arguably doesn't make sense for both settings to be used together, it would be a nasty surprise if these are coming from defaults

Minimal Reproduction

repro.py
def test_cannot_validate_assignment_when_frozen(): @pydantic.dataclasses.dataclass(config=ConfigDict(validate_assignment=True), frozen=True) class MyDataclass: a: int d = MyDataclass(2) assert d.a == 2 with pytest.raises(ValidationError) as exc_info: d.a = 3 assert exc_info.value.errors(include_url=False) == [ { 'type': 'frozen_instance', 'loc': ('a',), 'msg': 'Instance is frozen', 'input': '3', } ]

Environment

  • Pydantic: 2

What Broke

Dataclass fields remained mutable despite being marked as frozen, leading to unexpected behavior.

Why It Broke

The frozen setting was not properly enforced for dataclasses with validate_assignment enabled

Fix Options (Details)

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

pip install pydantic==1.10.18

When NOT to use: Do not use this fix if you require mutable fields in frozen 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/10066

First fixed release: 1.10.18

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

  • Do not use this fix if you require mutable fields in frozen 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.
  • Add a TLS smoke test that performs a real handshake in CI (include CA bundle validation and hostname checks).
  • Alert on handshake failures by error string and endpoint to catch cert/CA changes quickly.

Version Compatibility Table

VersionStatus
1.10.18 Fixed

Related Issues

No related fixes found.

Sources

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