The Fix
pip install pydantic==1.10.1
Based on closed pydantic/pydantic issue #9769 · PR/commit linked
@@ -0,0 +1,2 @@
@@ -0,0 +1,2 @@
+Allow `Field` with a `default_factory` to be used as an argument to a function
+decorated with `validate_arguments`
\ No newline at end of file
import datetime
from typing import Annotated, Optional
from pydantic import BaseModel, Field
# Model Definition
class Item(BaseModel):
id: Annotated[int, Field(title="Item ID")]
label: Annotated[str | None, Field(title="Item Label")] = None
created_at: Annotated[datetime.datetime | None, Field(title="Item Created At", default_factory=datetime.datetime.now)] = None
# Ok: Static Analysis Success.
item = Item(id=1)
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.1\nWhen NOT to use: This fix should not be used if the existing behavior of Field is required.\n\nOption C — Workaround\nmight be to define a small helper function:\nWhen NOT to use: This fix should not be used if the existing behavior of Field is required.\n\n
Why This Fix Works in Production
- Trigger: Annotated cannot be used, and Field must be assigned.
- Mechanism: The current implementation does not allow using Field with default_factory in Annotated
- Why the fix works: Adds preliminary support for Field to validate_arguments, allowing the use of default_factory in function arguments. (first fixed release: 1.10.1).
Why This Breaks in Prod
- Shows up under Python 3.12 in real deployments (not just unit tests).
- The current implementation does not allow using Field with default_factory in Annotated
- Production symptom (often without a traceback): Annotated cannot be used, and Field must be assigned.
Proof / Evidence
- GitHub issue: #9769
- Fix PR: https://github.com/pydantic/pydantic/pull/2176
- First fixed release: 1.10.1
- 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.59
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“@sydney-runkle Thanks for the response. Yes. I could not find an existing way to dictate **required** and **default**, and made a suggestion. If you have…”
“Just to clarify - when you specify the default_factory, it's inferred that the field is not required”
“Imo seems best for now to have it defined in user code, considering it is a two-line function, but I don't have strong opinions on…”
“Hi @yassun7010, Perhaps I'm misunderstanding your question - why does the following not suit your needs?”
Failure Signature (Search String)
- Annotated cannot be used, and Field must be assigned.
- The reason why `Annotated` cannot be used when using `default_factory` is to avoid specifying a field with `default_factory` when initializing in the constructor.
Copy-friendly signature
Failure Signature
-----------------
Annotated cannot be used, and Field must be assigned.
The reason why `Annotated` cannot be used when using `default_factory` is to avoid specifying a field with `default_factory` when initializing in the constructor.
Error Message
Signature-only (no traceback captured)
Error Message
-------------
Annotated cannot be used, and Field must be assigned.
The reason why `Annotated` cannot be used when using `default_factory` is to avoid specifying a field with `default_factory` when initializing in the constructor.
Minimal Reproduction
import datetime
from typing import Annotated, Optional
from pydantic import BaseModel, Field
# Model Definition
class Item(BaseModel):
id: Annotated[int, Field(title="Item ID")]
label: Annotated[str | None, Field(title="Item Label")] = None
created_at: Annotated[datetime.datetime | None, Field(title="Item Created At", default_factory=datetime.datetime.now)] = None
# Ok: Static Analysis Success.
item = Item(id=1)
Environment
- Python: 3.12
What Broke
Users cannot consistently declare fields with required and default values.
Why It Broke
The current implementation does not allow using Field with default_factory in Annotated
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install pydantic==1.10.1
Use when you can deploy the upstream fix. It is usually lower-risk than long-lived workarounds.
Option C — Workaround Temporary workaround
might be to define a small helper function:
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/2176
First fixed release: 1.10.1
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- This fix should not be used if the existing behavior of Field is required.
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.1 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.