Jump to solution
Verify

The Fix

Relaxed the check for validated data in default factory utilities to prevent breaking changes in Pydantic 2.10.

Based on closed pydantic/pydantic issue #10912 · 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
@@ -572,7 +572,9 @@ def deprecation_message(self) -> str | None: @overload - def get_default(self, *, call_default_factory: Literal[True], validated_data: dict[str, Any]) -> Any: ... + def get_default( + self, *, call_default_factory: Literal[True], validated_data: dict[str, Any] | None = None
repro.py
from typing import ClassVar, List, Set from pydantic import BaseModel, Field class PrefectBaseModel(BaseModel): _reset_fields: ClassVar[Set[str]] = set() def reset_fields(self): return self.model_copy( update={ field: self.model_fields[field].get_default(call_default_factory=True) for field in self._reset_fields } ) class TaskRun(PrefectBaseModel): _reset_fields: ClassVar[Set[str]] = {"tags"} name: str tags: List[str] = Field(default_factory=list) def main(): task = TaskRun(name="test-task") task.tags.append("new-tag") task.reset_fields() if __name__ == "__main__": main()
verify
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
fix.md
Option A — Apply the official fix\nRelaxed the check for validated data in default factory utilities to prevent breaking changes in Pydantic 2.10.\nWhen NOT to use: This fix should not be used if the application relies on the previous behavior of default factories.\n\nOption C — Workaround\nversion above\nWhen NOT to use: This fix should not be used if the application relies on the previous behavior of default factories.\n\n

Why This Fix Works in Production

  • Trigger: def get_default(self, *, call_default_factory: bool = False, validated_data: dict[str, Any] | None = None) -> Any:
  • Mechanism: Relaxed the check for validated data in default factory utilities to prevent breaking changes in Pydantic 2.10.
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.12 in real deployments (not just unit tests).
  • Surfaces as: def get_default(self, *, call_default_factory: bool = False, validated_data: dict[str, Any] | None = None) -> Any:

Proof / Evidence

Discussion

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

“Hey folks! We've just released v2.10.1 with a fix for this issue! Let us know if you're still experiencing any difficulties. Thanks!”
@sydney-runkle · 2024-11-22 · confirmation · source
“Just wanted to chime in that this broke creating new instances of SqlModels in the last few hours; will try and read through to understand…”
@joshuamckenty · 2024-11-21 · source
“> Any update on this? Broke our whole system. Let me know if we can help. Anyone knows the last working pydantic version? We should…”
@sydney-runkle · 2024-11-21 · source
“> EDIT: ok I think I get it. https://github.com/pydantic/pydantic/pull/10678, that's what we need to pass if we're going to tell it to call_default_factory at this…”
@zzstoatzz · 2024-11-21 · source

Failure Signature (Search String)

  • def get_default(self, *, call_default_factory: bool = False, validated_data: dict[str, Any] | None = None) -> Any:

Error Message

Stack trace
error.txt
Error Message ------------- def get_default(self, *, call_default_factory: bool = False, validated_data: dict[str, Any] | None = None) -> Any: ... if self.default_factory is None: return _utils.smart_deepcopy(self.default) elif call_default_factory: if validated_data is None: raise ValueError("'validated_data' must be provided if 'call_default_factory' is True.") E ValueError: 'validated_data' must be provided if 'call_default_factory' is True.
Stack trace
error.txt
Error Message ------------- » python sandbox/repros/pydantic210.py Traceback (most recent call last): File "/Users/nate/github.com/prefecthq/prefect/sandbox/repros/pydantic210.py", line 32, in <module> main() File "/Users/nate/github.com/prefecthq/prefect/sandbox/repros/pydantic210.py", line 28, in main task.reset_fields() File "/Users/nate/github.com/prefecthq/prefect/sandbox/repros/pydantic210.py", line 12, in reset_fields field: self.model_fields[field].get_default(call_default_factory=True) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/nate/github.com/prefecthq/prefect/.venv/lib/python3.12/site-packages/pydantic/fields.py", line 596, in get_default raise ValueError("'validated_data' must be provided if 'call_default_factory' is True.") ValueError: 'validated_data' must be provided if 'call_default_factory' is True. </details>
Stack trace
error.txt
Error Message ------------- » uv run --with prefect==3.1.3 --with pydantic==2.10.0 sandbox/repros/pydantic210.py Traceback (most recent call last): File "/Users/nate/github.com/prefecthq/prefect/sandbox/repros/pydantic210.py", line 34, in <module> main() File "/Users/nate/github.com/prefecthq/prefect/sandbox/repros/pydantic210.py", line 28, in main task.reset_fields() File "/Users/nate/github.com/prefecthq/prefect/sandbox/repros/pydantic210.py", line 12, in reset_fields field: self.model_fields[field].get_default(call_default_factory=True) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/nate/github.com/prefecthq/prefect/.venv/lib/python3.12/site-packages/pydantic/fields.py", line 596, in get_default raise ValueError("'validated_data' must be provided if 'call_default_factory' is True.") ValueError: 'validated_data' must be provided if 'call_default_factory' is True. » uv run --with prefect==3.1.3 --with pydantic@git+https://github.com/pydantic/pydantic.git@validated-data-fix sandbox/repros/pydantic210.py Updated https://github.com/pydantic/pydantic.git (69e509ef) name='test-task' tags=['new-tag']

Minimal Reproduction

repro.py
from typing import ClassVar, List, Set from pydantic import BaseModel, Field class PrefectBaseModel(BaseModel): _reset_fields: ClassVar[Set[str]] = set() def reset_fields(self): return self.model_copy( update={ field: self.model_fields[field].get_default(call_default_factory=True) for field in self._reset_fields } ) class TaskRun(PrefectBaseModel): _reset_fields: ClassVar[Set[str]] = {"tags"} name: str tags: List[str] = Field(default_factory=list) def main(): task = TaskRun(name="test-task") task.tags.append("new-tag") task.reset_fields() if __name__ == "__main__": main()

Environment

  • Python: 3.12
  • Pydantic: 2

Fix Options (Details)

Option A — Apply the official fix

Relaxed the check for validated data in default factory utilities to prevent breaking changes in Pydantic 2.10.

When NOT to use: This fix should not be used if the application relies on the previous behavior of default factories.

Option C — Workaround Temporary workaround

version above

When NOT to use: This fix should not be used if the application relies on the previous behavior of default factories.

Use only if you cannot change versions today. Treat this as a stopgap and remove once upgraded.

Fix reference: https://github.com/pydantic/pydantic/pull/10909

Last verified: 2026-02-11. Validate in your environment.

Get updates

We publish verified fixes weekly. No spam.

Subscribe

When NOT to Use This Fix

  • This fix should not be used if the application relies on the previous behavior of default factories.

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.

Related Issues

No related fixes found.

Sources

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