The Fix
Fixes an issue with forward annotations and serializers in Pydantic, specifically addressing the error '<model> is not fully defined'.
Based on closed pydantic/pydantic issue #10919 · 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%.
@@ -1920,7 +1920,12 @@ def _computed_field_schema(
) -> core_schema.ComputedField:
try:
- return_type = _decorators.get_function_return_type(d.func, d.info.return_type, *self._types_namespace)
+ # Do not pass in globals as the function could be defined in a different module.
+ # Instead, let `get_function_return_type` infer the globals to use, but still pass
from __future__ import annotations
from typing import Any, Dict
from pydantic import BaseModel, model_serializer
class BaseComponent(BaseModel):
@model_serializer(mode="wrap")
def custom_model_dump(self, handler: Any) -> Dict[str, Any]:
return handler(self)
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
Option A — Apply the official fix\nFixes an issue with forward annotations and serializers in Pydantic, specifically addressing the error '<model> is not fully defined'.\nWhen NOT to use: Do not apply this fix if your model relies on different serialization behavior.\n\n
Why This Fix Works in Production
- Trigger: I'm guessing @Viicos might have some insight here, looks related to our namespace management changes.
- Mechanism: The issue arises from improper handling of forward annotations in serializers
- 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
- The issue arises from improper handling of forward annotations in serializers
- Production symptom (often without a traceback): I'm guessing @Viicos might have some insight here, looks related to our namespace management changes.
Proof / Evidence
- GitHub issue: #10919
- Fix PR: https://github.com/pydantic/pydantic/pull/10929
- Reproduced locally: No (not executed)
- Last verified: 2026-02-11
- Confidence: 0.80
- 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).
“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!”
“I'm guessing @Viicos might have some insight here, looks related to our namespace management changes. Happy to take a look as well.”
Failure Signature (Search String)
- I'm guessing @Viicos might have some insight here, looks related to our namespace management changes.
Copy-friendly signature
Failure Signature
-----------------
I'm guessing @Viicos might have some insight here, looks related to our namespace management changes.
Error Message
Signature-only (no traceback captured)
Error Message
-------------
I'm guessing @Viicos might have some insight here, looks related to our namespace management changes.
Minimal Reproduction
from __future__ import annotations
from typing import Any, Dict
from pydantic import BaseModel, model_serializer
class BaseComponent(BaseModel):
@model_serializer(mode="wrap")
def custom_model_dump(self, handler: Any) -> Dict[str, Any]:
return handler(self)
Environment
- Pydantic: 2
What Broke
Users experience errors indicating that models are not fully defined during serialization.
Why It Broke
The issue arises from improper handling of forward annotations in serializers
Fix Options (Details)
Option A — Apply the official fix
Fixes an issue with forward annotations and serializers in Pydantic, specifically addressing the error '<model> is not fully defined'.
Fix reference: https://github.com/pydantic/pydantic/pull/10929
Last verified: 2026-02-11. Validate in your environment.
When NOT to Use This Fix
- Do not apply this fix if your model relies on different serialization behavior.
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.
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.