Jump to solution
Verify

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%.

Jump to Verify Open PR/Commit
@@ -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
repro.py
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)
verify
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
fix.md
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
Production impact:
  • 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

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!”
@sydney-runkle · 2024-11-22 · confirmation · source
“I'm guessing @Viicos might have some insight here, looks related to our namespace management changes. Happy to take a look as well.”
@sydney-runkle · 2024-11-21 · source

Failure Signature (Search String)

  • I'm guessing @Viicos might have some insight here, looks related to our namespace management changes.
Copy-friendly signature
signature.txt
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.txt
Error Message ------------- I'm guessing @Viicos might have some insight here, looks related to our namespace management changes.

Minimal Reproduction

repro.py
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'.

When NOT to use: Do not apply this fix if your model relies on different serialization behavior.

Fix reference: https://github.com/pydantic/pydantic/pull/10929

Last verified: 2026-02-11. Validate in your environment.

Get updates

We publish verified fixes weekly. No spam.

Subscribe

When NOT to Use This Fix

  • Do not apply this fix if your model relies on different serialization behavior.

Verify Fix

verify
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.