The Fix
pip install pydantic==1.10.18
Based on closed pydantic/pydantic issue #8732 · 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%.
@@ -49,6 +49,7 @@
PydanticDeprecatedSince20,
PydanticDeprecatedSince26,
+ PydanticDeprecatedSince29,
PydanticDeprecationWarning,
PydanticExperimentalWarning,
import pydantic
import jsonschema
class ValidModel(pydantic.BaseModel):
f: int = pydantic.Field(..., examples=[])
class InvalidModel(pydantic.BaseModel):
f: int = pydantic.Field(..., examples={})
print(pydantic.version.version_info())
print(ValidModel.schema_json(indent=2))
print(InvalidModel.schema_json(indent=2))
try:
jsonschema.validate(InvalidModel(f=1).dict(), InvalidModel.schema())
except jsonschema.exceptions.SchemaError as e:
print(e)
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 used if backward compatibility with existing code relying on dict examples is required.\n\n
Why This Fix Works in Production
- Trigger: Type of `examples` parameter is not checked, which may lead to invalid JSON schema generation
- Mechanism: The examples parameter type is not enforced, allowing invalid types leading to JSON schema generation errors
- Why the fix works: Deprecates passing a dict to the `Examples` class and adds support for passing examples as a list, addressing type checking issues in JSON schema generation. (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 examples parameter type is not enforced, allowing invalid types leading to JSON schema generation errors
- Production symptom (often without a traceback): Type of `examples` parameter is not checked, which may lead to invalid JSON schema generation
Proof / Evidence
- GitHub issue: #8732
- Fix PR: https://github.com/pydantic/pydantic/pull/10181
- First fixed release: 1.10.18
- 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.60
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“https://github.com/pydantic/pydantic/pull/10181 deprecated passing examples as a dict and added support for passing examples as a list. Marking the issue as closed, but I will create…”
“@kostunin, I think this falls under the same umbrella as https://github.com/pydantic/pydantic/issues/8714”
Failure Signature (Search String)
- Type of `examples` parameter is not checked, which may lead to invalid JSON schema generation
- Surprisingly, [`ajv-cli`](https://github.com/ajv-validator/ajv-cli) considers such schema as valid, but Python `jsonschema` raises an exception (below output of example code).
Copy-friendly signature
Failure Signature
-----------------
Type of `examples` parameter is not checked, which may lead to invalid JSON schema generation
Surprisingly, [`ajv-cli`](https://github.com/ajv-validator/ajv-cli) considers such schema as valid, but Python `jsonschema` raises an exception (below output of example code).
Error Message
Signature-only (no traceback captured)
Error Message
-------------
Type of `examples` parameter is not checked, which may lead to invalid JSON schema generation
Surprisingly, [`ajv-cli`](https://github.com/ajv-validator/ajv-cli) considers such schema as valid, but Python `jsonschema` raises an exception (below output of example code).
Minimal Reproduction
import pydantic
import jsonschema
class ValidModel(pydantic.BaseModel):
f: int = pydantic.Field(..., examples=[])
class InvalidModel(pydantic.BaseModel):
f: int = pydantic.Field(..., examples={})
print(pydantic.version.version_info())
print(ValidModel.schema_json(indent=2))
print(InvalidModel.schema_json(indent=2))
try:
jsonschema.validate(InvalidModel(f=1).dict(), InvalidModel.schema())
except jsonschema.exceptions.SchemaError as e:
print(e)
Environment
- Python: 3.11
- Pydantic: 2
What Broke
Invalid JSON schema generation can cause runtime validation failures in applications.
Why It Broke
The examples parameter type is not enforced, allowing invalid types leading to JSON schema generation errors
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/10181
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 used if backward compatibility with existing code relying on dict examples is required.
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.