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%.
@@ -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.
"""
from pydantic import BaseModel
class StrChild(str):
pass
class Model(BaseModel):
field: StrChild
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==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).
- 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
- GitHub issue: #9006
- Fix PR: https://github.com/pydantic/pydantic/pull/5737
- First fixed release: 1.10.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.41
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
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“@NothisIm, Thanks for your well thought out feature request”
“Ah ok, so a bit more clarification”
“Found the alternative - as documented here. Still think it would be better to have such simple cases supported out of the box without users…”
“thanks a lot for your replies 🙇♀️ I will stick to the workaround for now”
Error Message
Stack trace
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
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
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!
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.
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
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 |
|---|---|
| 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.