The Fix
pip install pydantic==2.10.3
Based on closed pydantic/pydantic issue #11004 · 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%.
@@ -63,13 +63,14 @@ def __get_pydantic_core_schema__(self, source_type: Any, handler: GetCoreSchemaH
"""
schema = handler(source_type)
- globalns, localns = handler._get_types_namespace()
try:
+ # Do not pass in globals as the function could be defined in a different module.
# File b
from __future__ import annotations # Deleting this will fix the issue. It was OK to use it before Pydantic 2.10.0
from typing import Annotated, Any
from pydantic import PlainSerializer
def serializer(value:Any) -> Any:
return value
Something = Annotated[Any, PlainSerializer(serializer)]
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.10.3\nWhen NOT to use: This fix should not be used if the code relies on future annotations for other functionalities.\n\n
Why This Fix Works in Production
- Trigger: Model(something=1)
- Mechanism: Fixes the issue where the Model is not fully defined when using from __future__ import annotations in Pydantic 2.10.x.
- Why the fix works: Fixes the issue where the Model is not fully defined when using from __future__ import annotations in Pydantic 2.10.x. (first fixed release: 2.10.3).
- 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
- Shows up under Python 3.12 in real deployments (not just unit tests).
- Surfaces as: Traceback (most recent call last):
Proof / Evidence
- GitHub issue: #11004
- Fix PR: https://github.com/pydantic/pydantic/pull/11008
- First fixed release: 2.10.3
- 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.42
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“Thanks for the bug report, this was an oversight in https://github.com/pydantic/pydantic/pull/10929. I will provide a fix for the next patch release.”
“I tried the new Pydantic release that includes fix for this issue and I can confirm it solves the issue. Thank you very much for…”
Failure Signature (Search String)
- Model(something=1)
Error Message
Stack trace
Error Message
-------------
Traceback (most recent call last):
File "...b.py", line 9, in <module>
Model(something=1)
File ".../lib/python3.12/site-packages/pydantic/main.py", line 214, in __init__
validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".../lib/python3.12/site-packages/pydantic/_internal/_mock_val_ser.py", line 100, in __getattr__
raise PydanticUserError(self._error_message, code=self._code)
pydantic.errors.PydanticUserError: `Model` is not fully defined; you should define `Any`, then call `Model.model_rebuild()`.
For further information visit https://errors.pydantic.dev/2.10/u/class-not-fully-defined
Minimal Reproduction
# File b
from __future__ import annotations # Deleting this will fix the issue. It was OK to use it before Pydantic 2.10.0
from typing import Annotated, Any
from pydantic import PlainSerializer
def serializer(value:Any) -> Any:
return value
Something = Annotated[Any, PlainSerializer(serializer)]
Environment
- Python: 3.12
- Pydantic: 2
What Broke
Users encounter PydanticUserError indicating the Model is not fully defined.
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install pydantic==2.10.3
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/11008
First fixed release: 2.10.3
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- This fix should not be used if the code relies on future annotations for other functionalities.
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.10.3 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.