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%.
@@ -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,
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',
}
]
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.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).
- 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
- GitHub issue: #10041
- Fix PR: https://github.com/pydantic/pydantic/pull/10066
- First fixed release: 1.10.18
- Reproduced locally: No (not executed)
- Last verified: 2026-02-09
- Confidence: 0.85
- Did this fix it?: Yes (upstream fix exists)
- Own content ratio: 0.54
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
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…”
“@czlr, Good find, definitely a bug. Help with a fix is welcome!”
“Hi @sydney-runkle, everybody, I took some time to see if I could have helped with this”
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
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 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
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
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.
When NOT to Use This Fix
- Do not use this fix if you require mutable fields in frozen 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.
- 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
| Version | Status |
|---|---|
| 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.