The Fix
pip install pydantic==2.9.0
Based on closed pydantic/pydantic issue #10284 · PR/commit linked
@@ -191,6 +191,7 @@ def validated_setattr(instance: Any, field: str, value: str, /) -> None:
cls.__setattr__ = validated_setattr.__get__(None, cls) # type: ignore
+ cls.__pydantic_complete__ = True
return True
from pydantic.dataclasses import dataclass, rebuild_dataclass
@dataclass
class Point:
x: float
y: float
color: 'Color'
print(Point.__pydantic_complete__) # False: Color is not known yet
print(rebuild_dataclass(Point, raise_errors=False)) # False: the dataclass can't be rebuilt
# Now, we define color
@dataclass
class Color:
name: str
print(rebuild_dataclass(Point)) # True: the dataclass has been rebuilt!
print(Point(x=12, y=-2, color={"name": "red"})) # Check that the dataclass works correctly
# This should be True now that the dataclass has been rebuilt
# However, it is still False
print(Point.__pydantic_complete__)
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.9.0\nWhen NOT to use: This fix should not be applied if the behavior of `__pydantic_complete__` is intentionally designed to remain unchanged.\n\n
Why This Fix Works in Production
- Trigger: print(rebuild_dataclass(Point, raise_errors=False)) # False: the dataclass can't be rebuilt
- Mechanism: The `__pydantic_complete__` field is not updated after calling `rebuild_dataclass`
- Why the fix works: Ensure `__pydantic_complete__` is set when rebuilding dataclasses. (first fixed release: 2.9.0).
- If left unfixed, this can cause silent data inconsistencies that propagate (bad cache entries, incorrect downstream decisions).
Why This Breaks in Prod
- Shows up under Python 3.10 in real deployments (not just unit tests).
- The `__pydantic_complete__` field is not updated after calling `rebuild_dataclass`
- Production symptom (often without a traceback): print(rebuild_dataclass(Point, raise_errors=False)) # False: the dataclass can't be rebuilt
Proof / Evidence
- GitHub issue: #10284
- Fix PR: https://github.com/pydantic/pydantic/pull/10291
- First fixed release: 2.9.0
- Reproduced locally: No (not executed)
- Last verified: 2026-02-09
- Confidence: 0.95
- Did this fix it?: Yes (upstream fix exists)
- Own content ratio: 0.55
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: 2.9.0
- Mode: fixed_only
- Outcome: ok
Logs
False
False
True
Point(x=12.0, y=-2.0, color=Color(name='red'))
True
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“Thanks for the bug report, pushing a fix.”
Failure Signature (Search String)
- print(rebuild_dataclass(Point, raise_errors=False)) # False: the dataclass can't be rebuilt
Copy-friendly signature
Failure Signature
-----------------
print(rebuild_dataclass(Point, raise_errors=False)) # False: the dataclass can't be rebuilt
Error Message
Signature-only (no traceback captured)
Error Message
-------------
print(rebuild_dataclass(Point, raise_errors=False)) # False: the dataclass can't be rebuilt
Minimal Reproduction
from pydantic.dataclasses import dataclass, rebuild_dataclass
@dataclass
class Point:
x: float
y: float
color: 'Color'
print(Point.__pydantic_complete__) # False: Color is not known yet
print(rebuild_dataclass(Point, raise_errors=False)) # False: the dataclass can't be rebuilt
# Now, we define color
@dataclass
class Color:
name: str
print(rebuild_dataclass(Point)) # True: the dataclass has been rebuilt!
print(Point(x=12, y=-2, color={"name": "red"})) # Check that the dataclass works correctly
# This should be True now that the dataclass has been rebuilt
# However, it is still False
print(Point.__pydantic_complete__)
Environment
- Python: 3.10
- Pydantic: 2
What Broke
Repeated calls to `rebuild_dataclass` unnecessarily rebuild the dataclass, impacting performance.
Why It Broke
The `__pydantic_complete__` field is not updated after calling `rebuild_dataclass`
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install pydantic==2.9.0
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/10291
First fixed release: 2.9.0
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- This fix should not be applied if the behavior of `__pydantic_complete__` is intentionally designed to remain unchanged.
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.9.0 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.