Jump to solution
Verify

The Fix

pip install pydantic==1.10.8

Based on closed pydantic/pydantic issue #9006 · 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
@@ -262,7 +262,7 @@ try: print(e.message) """ - Unable to generate pydantic-core schema for <class '__main__.ArbitraryType'>. Setting `arbitrary_types_allowed=True` in the model_config may prevent this error. + Unable to generate pydantic-core schema for <class '__main__.ArbitraryType'>. Set `arbitrary_types_allowed=True` in the model_config ignore this error or implement `__get_pydantic_core_schema__` on your type to fully support it. """
repro.py
from pydantic import BaseModel class StrChild(str): pass class Model(BaseModel): field: StrChild
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==1.10.8\nWhen NOT to use: This fix should not be used if the custom type requires specific validation logic that is not covered.\n\nOption C — Workaround\nwith the custom schema definitions is the best way forward, for now! Closing as resolved, but I'll reopen if it turns out we'd consider a change!\nWhen NOT to use: This fix should not be used if the custom type requires specific validation logic that is not covered.\n\n

Why This Fix Works in Production

  • Mechanism: Pydantic V2 does not automatically handle subclasses of known types, causing schema generation errors
  • Why the fix works: Addresses the issue of not automatically handling subclasses of known types in Pydantic, providing a workaround for users. (first fixed release: 1.10.8).
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.11 in real deployments (not just unit tests).
  • Pydantic V2 does not automatically handle subclasses of known types, causing schema generation errors
  • Surfaces as: Traceback (most recent call last):

Proof / Evidence

Verified Execution

We executed the runnable minimal repro in a temporary environment and captured exit codes + logs.

  • Status: PASS
  • Ran: 2026-02-11T16:52:29Z
  • Package: pydantic
  • Fixed: 1.10.8
  • Mode: fixed_only
  • Outcome: ok
Logs
affected (exit=None)
fixed (exit=0)

Discussion

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

“@NothisIm, Thanks for your well thought out feature request”
@sydney-runkle · 2024-03-17 · confirmation · source
“Ah ok, so a bit more clarification”
@sydney-runkle · 2024-03-17 · source
“Found the alternative - as documented here. Still think it would be better to have such simple cases supported out of the box without users…”
@NothisIm · 2024-03-14 · source
“thanks a lot for your replies 🙇‍♀️ I will stick to the workaround for now”
@NothisIm · 2024-03-18 · source

Error Message

Stack trace
error.txt
Error Message ------------- Traceback (most recent call last): ... File "<input>", line 10, in <module> File ".../lib/python3.11/site-packages/pydantic/_internal/_model_construction.py", line 183, in __new__ complete_model_class( File ".../lib/python3.11/site-packages/pydantic/_internal/_model_construction.py", line 517, in complete_model_class schema = cls.__get_pydantic_core_schema__(cls, handler) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File ".../lib/python3.11/site-packages/pydantic/main.py", line 584, in __get_pydantic_core_schema__ return __handler(__source) ^^^^^^^^^^^^^^^^^^^ File ".../lib/python3.11/site-packages/pydantic/_internal/_schema_generation_shared.py", line 82, in __call__ schema = self._handler(__source_type) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File ".../lib/python3.11/site-packages/pydantic/_internal/_generate_schema.py", line 499, in generate_schema schema = self._generate_schema(obj) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File ".../lib/python3.11/site-packages/pydantic/_internal/_generate_schema.py", line 737, in _generate_schema schema = self._post_process_generated_schema(self._generate_schema_inner(obj)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File ".../lib/python3.11/site-packages/pydantic/_internal/_generate_schema.py", line 759, in _generate_schema_inner r ... (truncated) ...

Minimal Reproduction

repro.py
from pydantic import BaseModel class StrChild(str): pass class Model(BaseModel): field: StrChild

Environment

  • Python: 3.11
  • Pydantic: 2

What Broke

Users encounter errors when using subclasses of str in Pydantic models, leading to validation failures.

Why It Broke

Pydantic V2 does not automatically handle subclasses of known types, causing schema generation errors

Fix Options (Details)

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

pip install pydantic==1.10.8

When NOT to use: This fix should not be used if the custom type requires specific validation logic that is not covered.

Use when you can deploy the upstream fix. It is usually lower-risk than long-lived workarounds.

Option C — Workaround Temporary workaround

with the custom schema definitions is the best way forward, for now! Closing as resolved, but I'll reopen if it turns out we'd consider a change!

When NOT to use: This fix should not be used if the custom type requires specific validation logic that is not covered.

Use only if you cannot change versions today. Treat this as a stopgap and remove once upgraded.

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

First fixed release: 1.10.8

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 should not be used if the custom type requires specific validation logic that is not covered.

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
1.10.8 Fixed

Related Issues

No related fixes found.

Sources

We don’t republish the full GitHub discussion text. Use the links above for context.