Jump to solution
Verify

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

Jump to Verify Open PR/Commit
@@ -49,6 +49,7 @@ PydanticDeprecatedSince20, PydanticDeprecatedSince26, + PydanticDeprecatedSince29, PydanticDeprecationWarning, PydanticExperimentalWarning,
repro.py
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)
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.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).
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).
  • 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

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…”
@Viicos · 2024-08-20 · source
“@kostunin, I think this falls under the same umbrella as https://github.com/pydantic/pydantic/issues/8714”
@sydney-runkle · 2024-02-06 · source

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
signature.txt
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.txt
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

repro.py
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

When NOT to use: This fix should not be used if backward compatibility with existing code relying on dict examples is required.

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.

Get updates

We publish verified fixes weekly. No spam.

Subscribe

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

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.18 Fixed

Related Issues

No related fixes found.

Sources

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