Jump to solution
Verify

The Fix

pip install pydantic==2.11.0

Based on closed pydantic/pydantic issue #11346 · 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
@@ -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'
repro.py
from typing import TypedDict import pydantic from typing_extensions import ReadOnly class Foo(TypedDict): foo: ReadOnly[str] adapter = pydantic.TypeAdapter(Foo) foo = adapter.validate_python({"foo": "bar"}) print(foo["foo"])
verify
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
fix.md
Option A — Upgrade to fixed release\npip install pydantic==2.11.0\nWhen NOT to use: This fix is not suitable if strict immutability is required for typed dictionaries.\n\n

Why This Fix Works in Production

  • Trigger: E pydantic.errors.PydanticSchemaGenerationError: Unable to generate pydantic-core schema for typing_extensions.ReadOnly[str]. Set…
  • Mechanism: Added support for `typing.ReadOnly` in Pydantic to prevent schema generation errors when using typed dictionaries.
  • Why the fix works: Added support for `typing.ReadOnly` in Pydantic to prevent schema generation errors when using typed dictionaries. (first fixed release: 2.11.0).
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

  • Shows up under Python 3.12 in real deployments (not just unit tests).
  • Surfaces as: E pydantic.errors.PydanticSchemaGenerationError: Unable to generate pydantic-core schema for typing_extensions.ReadOnly[str]. Set `arbitrary_types_allowed=True` in the…

Proof / Evidence

Discussion

High-signal excerpts from the issue thread (symptoms, repros, edge-cases).

“For my use case, this works perfectly. I don't really need a runtime check as I know typeddicts are a special type from.”
@mezuzza · 2025-02-12 · source
“Support for ReadOnly will be added, however it might not work as you would expect, as Pydantic can't prevent mutations on dictionaries: For this reason,…”
@Viicos · 2025-02-12 · source

Failure Signature (Search String)

  • E pydantic.errors.PydanticSchemaGenerationError: Unable to generate pydantic-core schema for typing_extensions.ReadOnly[str]. Set `arbitrary_types_allowed=True` in the

Error Message

Stack trace
error.txt
Error Message ------------- E pydantic.errors.PydanticSchemaGenerationError: Unable to generate pydantic-core schema for typing_extensions.ReadOnly[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. E E If you got this error by calling handler(<some type>) within `__get_pydantic_core_schema__` then you likely need to call `handler.generate_schema(<some type>)` since we do not call `__get_pydantic_core_schema__` on `<some type>` otherwise to avoid infinite recursion. E E For further information visit https://errors.pydantic.dev/2.10/u/schema-for-unknown-type

Minimal Reproduction

repro.py
from typing import TypedDict import pydantic from typing_extensions import ReadOnly class Foo(TypedDict): foo: ReadOnly[str] adapter = pydantic.TypeAdapter(Foo) foo = adapter.validate_python({"foo": "bar"}) print(foo["foo"])

Environment

  • Python: 3.12
  • Pydantic: 2

What Broke

Users encounter schema generation errors when using ReadOnly in FastAPI typed dictionaries.

Fix Options (Details)

Option A — Upgrade to fixed release Safe default (recommended)

pip install pydantic==2.11.0

When NOT to use: This fix is not suitable if strict immutability is required for typed dictionaries.

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.

Get updates

We publish verified fixes weekly. No spam.

Subscribe

When NOT to Use This Fix

  • This fix is not suitable if strict immutability is required for typed dictionaries.

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.

Version Compatibility Table

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