The Fix
pip install pydantic==1.10.18
Based on closed pydantic/pydantic issue #10031 · 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%.
@@ -265,11 +265,6 @@ def modify_model_json_schema(
json_schema = handler(schema_or_field)
original_schema = handler.resolve_ref_schema(json_schema)
- # Preserve the fact that definitions schemas should never have sibling keys:
- if '$ref' in original_schema:
- ref = original_schema['$ref']
from pydantic import BaseModel, ConfigDict, Field
class Test(BaseModel):
val: str = "test"
class Foo(BaseModel):
bar: Test = Field(description="test")
quz: Test
Foo.model_json_schema()
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.18\nWhen NOT to use: This fix should not be applied if the behavior of allOf is required for specific schema validation.\n\n
Why This Fix Works in Production
- Trigger: JSON schema uses allOf when adding Field(description="")
- Mechanism: The JSON schema incorrectly adds an allOf wrapper when a description is provided for a Field
- Why the fix works: Removes the unnecessary allOf JSON schema workarounds, allowing sibling keys alongside $ref keys. (first fixed release: 1.10.18).
- 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).
- The JSON schema incorrectly adds an allOf wrapper when a description is provided for a Field
- Production symptom (often without a traceback): JSON schema uses allOf when adding Field(description="")
Proof / Evidence
- GitHub issue: #10031
- Fix PR: https://github.com/pydantic/pydantic/pull/10029
- First fixed release: 1.10.18
- Reproduced locally: No (not executed)
- Last verified: 2026-02-09
- Confidence: 0.85
- Did this fix it?: Yes (upstream fix exists)
- Own content ratio: 0.64
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“Hi @kwint, Thanks for reporting this. I think this should be fixed by https://github.com/pydantic/pydantic/pull/10029 :)”
Failure Signature (Search String)
- JSON schema uses allOf when adding Field(description="")
- When adding a description to a Field the schema adds an extra layer with an `allOf` array.
Copy-friendly signature
Failure Signature
-----------------
JSON schema uses allOf when adding Field(description="")
When adding a description to a Field the schema adds an extra layer with an `allOf` array.
Error Message
Signature-only (no traceback captured)
Error Message
-------------
JSON schema uses allOf when adding Field(description="")
When adding a description to a Field the schema adds an extra layer with an `allOf` array.
Minimal Reproduction
from pydantic import BaseModel, ConfigDict, Field
class Test(BaseModel):
val: str = "test"
class Foo(BaseModel):
bar: Test = Field(description="test")
quz: Test
Foo.model_json_schema()
Environment
- Python: 3.11
- Pydantic: 2
What Broke
The generated JSON schema does not match the expected format, causing integration issues.
Why It Broke
The JSON schema incorrectly adds an allOf wrapper when a description is provided for a Field
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install pydantic==1.10.18
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/10029
First fixed release: 1.10.18
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- This fix should not be applied if the behavior of allOf is required for specific schema 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 |
|---|---|
| 1.10.18 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.