The Fix
pip install pydantic==2.11.0
Based on closed pydantic/pydantic issue #11510 · 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%.
@@ -297,7 +297,8 @@ jobs:
- name: Run ODMantic tests
- run: pytest tests
+ # Disabled tests, as per https://github.com/art049/odmantic/issues/512:
+ run: pytest tests -k 'not test_custom_bson_serializable and not test_sync_custom_bson_serializable and not test_with_bson_serializer_override_builtin_bson'
import typing as _t
from pydantic import BaseModel, Field
class MyTypedDict(_t.TypedDict):
x: _t.Annotated[_t.NotRequired[str], Field(pattern="test[xyz]")] # Does not work
y: _t.NotRequired[str] # This works
z: _t.Annotated[str, Field(default="hello")] # This works
class ComponentSpec(BaseModel):
name: str
args: MyTypedDict
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.0\nWhen NOT to use: This fix should not be used if `arbitrary_types_allowed` is not set to True.\n\n
Why This Fix Works in Production
- Trigger: pydantic.errors.PydanticSchemaGenerationError: Unable to generate pydantic-core schema for typing.NotRequired[str]. Set `arbitrary_types_allowed=True` in the…
- Mechanism: Using `Annotated` with `NotRequired` types in `TypedDict` caused schema generation errors
- Why the fix works: Fixes an issue where using `Annotated` with `NotRequired` types in `TypedDict` objects caused schema generation errors. (first fixed release: 2.11.0).
- 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).
- Using `Annotated` with `NotRequired` types in `TypedDict` caused schema generation errors
- Surfaces as: pydantic.errors.PydanticSchemaGenerationError: Unable to generate pydantic-core schema for typing.NotRequired[str]. Set `arbitrary_types_allowed=True` in the model_config to…
Proof / Evidence
- GitHub issue: #11510
- Fix PR: https://github.com/pydantic/pydantic/pull/11479
- First fixed release: 2.11.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.61
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“This just so happens to be fixed by https://github.com/pydantic/pydantic/pull/11479, which was merged a couple days ago. The fix will be included in 2.11.”
Failure Signature (Search String)
- pydantic.errors.PydanticSchemaGenerationError: Unable to generate pydantic-core schema for typing.NotRequired[str]. Set `arbitrary_types_allowed=True` in the model_config to
Error Message
Stack trace
Error Message
-------------
pydantic.errors.PydanticSchemaGenerationError: Unable to generate pydantic-core schema for typing.NotRequired[str]. Set `arbitrary_types_allowed=True` in the model_config to ignore this error or implement `__get_pydantic_core_schema__` on your type to fully support it.
Minimal Reproduction
import typing as _t
from pydantic import BaseModel, Field
class MyTypedDict(_t.TypedDict):
x: _t.Annotated[_t.NotRequired[str], Field(pattern="test[xyz]")] # Does not work
y: _t.NotRequired[str] # This works
z: _t.Annotated[str, Field(default="hello")] # This works
class ComponentSpec(BaseModel):
name: str
args: MyTypedDict
Environment
- Python: 3.12
- Pydantic: 2
What Broke
Schema generation errors occurred when using `Annotated` with `NotRequired` in production.
Why It Broke
Using `Annotated` with `NotRequired` types in `TypedDict` caused schema generation errors
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install pydantic==2.11.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/11479
First fixed release: 2.11.0
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- This fix should not be used if `arbitrary_types_allowed` is not set to True.
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.0 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.