The Fix
pip install pydantic==2.11.8
Based on closed pydantic/pydantic issue #11682 · 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%.
@@ -802,6 +802,33 @@ Pydantic provides a few special utilities that can be used to customize validati
warning during serialization.
+* [`ValidateAs`][pydantic.functional_validators.ValidateAs] can be used to validate an custom type from a
+ type natively supported by Pydantic. This is particularly useful when using custom types with multiple fields.
+
λ python -c "import pydantic.version; print(pydantic.version.version_info())"
pydantic version: 2.11.1
pydantic-core version: 2.33.0
pydantic-core build: profile=release pgo=false
python version: 3.11.11 | packaged by conda-forge | (main, Mar 3 2025, 20:43:55) [GCC 13.3.0]
platform: Linux-4.18.0-553.33.1.el8_10.x86_64-x86_64-with-glibc2.28
related packages: mypy-1.15.0 fastapi-0.103.0 pydantic-extra-types-2.6.0 pydantic-settings-2.8.1 typing_extensions-4.13.0
commit: unknown
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.11.8\nWhen NOT to use: Do not use this fix if your model relies on BaseModel for validation.\n\n
Why This Fix Works in Production
- Trigger: pydantic.errors.PydanticUserError: `MyModel` is not fully defined; you should define all referenced types, then call `MyModel.model_rebuild()`.
- Mechanism: Nested annotation references in Pydantic models were not fully defined, causing instantiation errors
- Why the fix works: Introduced a new `ValidateAs` helper to ease the definition of validation logic for arbitrary classes with several fields, addressing the issue of nested annotation references in Pydantic models. (first fixed release: 2.11.8).
- 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
- Nested annotation references in Pydantic models were not fully defined, causing instantiation errors
- Surfaces as: pydantic.errors.PydanticUserError: `MyModel` is not fully defined; you should define all referenced types, then call `MyModel.model_rebuild()`.
Proof / Evidence
- GitHub issue: #11682
- Fix PR: https://github.com/pydantic/pydantic/pull/11942
- First fixed release: 2.11.8
- 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.54
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“The code you provided isn't supported by Pydantic. It may used to work by accident, but shouldn't be defined this way. If you are trying…”
“I think we can get this to work for you. Let's dicuss on the call next week.”
“Thanks, I see what you are saying now”
“Ok”
Failure Signature (Search String)
- pydantic.errors.PydanticUserError: `MyModel` is not fully defined; you should define all referenced types, then call `MyModel.model_rebuild()`.
Error Message
Stack trace
Error Message
-------------
pydantic.errors.PydanticUserError: `MyModel` is not fully defined; you should define all referenced types, then call `MyModel.model_rebuild()`.
Minimal Reproduction
λ python -c "import pydantic.version; print(pydantic.version.version_info())"
pydantic version: 2.11.1
pydantic-core version: 2.33.0
pydantic-core build: profile=release pgo=false
python version: 3.11.11 | packaged by conda-forge | (main, Mar 3 2025, 20:43:55) [GCC 13.3.0]
platform: Linux-4.18.0-553.33.1.el8_10.x86_64-x86_64-with-glibc2.28
related packages: mypy-1.15.0 fastapi-0.103.0 pydantic-extra-types-2.6.0 pydantic-settings-2.8.1 typing_extensions-4.13.0
commit: unknown
Environment
- Pydantic: 2
What Broke
Models fail to instantiate, leading to application errors and potential downtime.
Why It Broke
Nested annotation references in Pydantic models were not fully defined, causing instantiation errors
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install pydantic==2.11.8
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/11942
First fixed release: 2.11.8
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- Do not use this fix if your model relies on BaseModel for validation.
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.11.8 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.