The Fix
pip install pydantic==1.10.19
Based on closed pydantic/pydantic issue #8603 · PR/commit linked
@@ -372,21 +372,12 @@ jobs:
test-typing-extensions:
- name: test typing-extensions ${{ matrix.typing-extensions-version }} on Python ${{ matrix.python-version }}
+ name: test typing-extensions (`main` branch) on Python ${{ matrix.python-version }}
runs-on: ubuntu-latest
from pydantic import BaseModel, Field, model_validator
from typing import Optional
# Works, but a lot of code
class MyModel(BaseModel):
a: int
b: Optional[int] = None
@model_validator(mode="before")
@classmethod
def validate(cls, values):
values.setdefault("b", 5 * values["a"])
return values
# Works, but still a lot of code
class MyModel2(BaseModel):
a: int
b: Optional[int] = None
def __init__(self, **kwargs):
kwargs.setdefault("b", 5 * kwargs["a"])
super().__init__(**kwargs)
print(MyModel(a=1))
print(MyModel2(a=2))
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.19\nWhen NOT to use: This fix should not be used if backward compatibility with existing models is a concern.\n\n
Why This Fix Works in Production
- Trigger: - [ ] [Compatibility between releases](https://docs.pydantic.dev/changelog/)
- Mechanism: The library lacked support for default factories that accept validated data as arguments
- Why the fix works: Introduces support for default factories that can take validated data as an argument, addressing the issue of dependent defaults in Pydantic models. (first fixed release: 1.10.19).
Why This Breaks in Prod
- The library lacked support for default factories that accept validated data as arguments
- Production symptom (often without a traceback): - [ ] [Compatibility between releases](https://docs.pydantic.dev/changelog/)
Proof / Evidence
- GitHub issue: #8603
- Fix PR: https://github.com/pydantic/pydantic/pull/10678
- First fixed release: 1.10.19
- 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.53
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“Thanks for the comment @sydney-runkle! I think the DependentDefault is a good solution for now. I agree it makes sense to wait and see whether…”
“Improved version of https://github.com/pydantic/pydantic/issues/8603#issuecomment-2264988605 that also works with models that use validate_default=True by default, e.g. pydantic_settings.BaseSettings:”
“Just for completeness, I found a more compact way of expressing this: However I think it is still not as elegant as the default factory…”
“One disadvantage of the solution provided in https://github.com/pydantic/pydantic/issues/8603#issuecomment-1904939403 is that the static annotation is lost, because it is set at runtime. Running mypy on gives…”
Failure Signature (Search String)
- - [ ] [Compatibility between releases](https://docs.pydantic.dev/changelog/)
- - [X] [Data validation/parsing](https://docs.pydantic.dev/concepts/models/#basic-model-usage)
Copy-friendly signature
Failure Signature
-----------------
- [ ] [Compatibility between releases](https://docs.pydantic.dev/changelog/)
- [X] [Data validation/parsing](https://docs.pydantic.dev/concepts/models/#basic-model-usage)
Error Message
Signature-only (no traceback captured)
Error Message
-------------
- [ ] [Compatibility between releases](https://docs.pydantic.dev/changelog/)
- [X] [Data validation/parsing](https://docs.pydantic.dev/concepts/models/#basic-model-usage)
Minimal Reproduction
from pydantic import BaseModel, Field, model_validator
from typing import Optional
# Works, but a lot of code
class MyModel(BaseModel):
a: int
b: Optional[int] = None
@model_validator(mode="before")
@classmethod
def validate(cls, values):
values.setdefault("b", 5 * values["a"])
return values
# Works, but still a lot of code
class MyModel2(BaseModel):
a: int
b: Optional[int] = None
def __init__(self, **kwargs):
kwargs.setdefault("b", 5 * kwargs["a"])
super().__init__(**kwargs)
print(MyModel(a=1))
print(MyModel2(a=2))
What Broke
Users faced increased complexity and verbosity when defining dependent defaults in models.
Why It Broke
The library lacked support for default factories that accept validated data as arguments
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install pydantic==1.10.19
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/10678
First fixed release: 1.10.19
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- This fix should not be used if backward compatibility with existing models is a concern.
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.19 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.