The Fix
pip install pydantic==2.6.2
Based on closed pydantic/pydantic issue #8629 · PR/commit linked
@@ -574,7 +574,9 @@ def __repr_args__(self) -> ReprArgs:
if s == 'serialization_alias' and self.serialization_alias == self.alias:
continue
- if s == 'default_factory' and self.default_factory is not None:
+ if s == 'default' and self.default is not PydanticUndefined:
+ yield 'default', self.default
from pprint import pprint
import pydantic
class Foo(pydantic.BaseModel):
a: str = pydantic.Field("ADEF", alias="A")
b: int = pydantic.Field(..., alias="B")
c: str | None = pydantic.Field(None, alias="C")
pprint(Foo.model_fields)
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==2.6.2\nWhen NOT to use: This fix should not be used if the default value behavior is critical for existing model definitions.\n\n
Why This Fix Works in Production
- Trigger: This is more a quality of live improvement than anything else. With the proposed change, it's easier to inspect model definitions at a glance (and it's also…
- Mechanism: The __repr_args__ method in FieldInfo does not include the default value when explicitly set to None
- Why the fix works: Fixes the issue where FieldInfo.__repr_args__ does not include the default value when it is explicitly set to None. (first fixed release: 2.6.2).
Why This Breaks in Prod
- Shows up under Python 3.11 in real deployments (not just unit tests).
- The __repr_args__ method in FieldInfo does not include the default value when explicitly set to None
- Production symptom (often without a traceback): This is more a quality of live improvement than anything else. With the proposed change, it's easier to inspect model definitions at a glance (and it's also less confusing)
Proof / Evidence
- GitHub issue: #8629
- Fix PR: https://github.com/pydantic/pydantic/pull/8801
- First fixed release: 2.6.2
- 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.61
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“@Evenfire, Thanks for pointing this out! I agree with your suggested change. Please open a PR, and I'd be happy to review :).”
“@Evenfire, This issue is quite related - https://github.com/pydantic/pydantic/issues/8634. Would you be interested in taking a stab at a fix for that one as well? Thanks…”
“@sydney-runkle I'll open a PR for this issue as soon as I have few minutes.”
Failure Signature (Search String)
- This is more a quality of live improvement than anything else. With the proposed change, it's easier to inspect model definitions at a glance (and it's also less confusing)
Copy-friendly signature
Failure Signature
-----------------
This is more a quality of live improvement than anything else. With the proposed change, it's easier to inspect model definitions at a glance (and it's also less confusing)
python version: 3.11.7 (main, Jan 7 2024, 10:09:49) [Clang 15.0.0 (clang-1500.1.0.2.5)]
Error Message
Signature-only (no traceback captured)
Error Message
-------------
This is more a quality of live improvement than anything else. With the proposed change, it's easier to inspect model definitions at a glance (and it's also less confusing)
python version: 3.11.7 (main, Jan 7 2024, 10:09:49) [Clang 15.0.0 (clang-1500.1.0.2.5)]
Minimal Reproduction
from pprint import pprint
import pydantic
class Foo(pydantic.BaseModel):
a: str = pydantic.Field("ADEF", alias="A")
b: int = pydantic.Field(..., alias="B")
c: str | None = pydantic.Field(None, alias="C")
pprint(Foo.model_fields)
Environment
- Python: 3.11
- Pydantic: 2
What Broke
FieldInfo representation does not show default values, causing confusion during model inspection.
Why It Broke
The __repr_args__ method in FieldInfo does not include the default value when explicitly set to None
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install pydantic==2.6.2
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/8801
First fixed release: 2.6.2
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- This fix should not be used if the default value behavior is critical for existing model definitions.
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 |
|---|---|
| 2.6.2 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.