Jump to solution
Verify

The Fix

pip install pydantic==1.10.15

Based on closed pydantic/pydantic issue #8905 · 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
@@ -732,24 +732,22 @@ def literal_schema(self, schema: core_schema.LiteralSchema) -> JsonSchemaValue: expected = [to_jsonable_python(v) for v in expected] + result: dict[str, Any] = {'enum': expected} if len(expected) == 1: - return {'const': expected[0]}
repro.py
from pydantic import BaseModel from typing import Literal class Foo(BaseModel): bar: Literal["Bar"] = 'Bar' baz: Literal[None] = None
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.15\nWhen NOT to use: This fix should not be applied if backward compatibility with existing JSON schemas is a concern.\n\n

Why This Fix Works in Production

  • Trigger: `Literal` annotation does not render type to json-schema
  • Mechanism: The JSON schema generation for single item literals did not include type information
  • Why the fix works: Adds enum and type to the JSON schema for single item literals, addressing the issue where Literal annotations do not render types correctly in the JSON schema. (first fixed release: 1.10.15).
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

  • The JSON schema generation for single item literals did not include type information
  • Production symptom (often without a traceback): `Literal` annotation does not render type to json-schema

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.15
  • Mode: fixed_only
  • Outcome: ok
Logs
affected (exit=None)
fixed (exit=0)

Discussion

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

“Ah, now I understand”
@dmontagu · 2024-03-04 · source
“@WillDaSilva does the following not work for you? More generally though, I think we should do a better job of handling single-item literals as I…”
@dmontagu · 2024-03-04 · source
“@dmontagu That works for when the list of possible values is static (i.e. hard-coded), but when you have the list of strings as a variable…”
@WillDaSilva · 2024-03-04 · source
“@bruno-f-cruz does the change proposed in #8944 address your issue, or do you otherwise have any problems with it? It goes a bit farther than…”
@dmontagu · 2024-03-04 · source

Failure Signature (Search String)

  • `Literal` annotation does not render type to json-schema
  • The output json-schema model loses the typing of the variable used for the literal. I.e.:
Copy-friendly signature
signature.txt
Failure Signature ----------------- `Literal` annotation does not render type to json-schema The output json-schema model loses the typing of the variable used for the literal. I.e.:

Error Message

Signature-only (no traceback captured)
error.txt
Error Message ------------- `Literal` annotation does not render type to json-schema The output json-schema model loses the typing of the variable used for the literal. I.e.:

Minimal Reproduction

repro.py
from pydantic import BaseModel from typing import Literal class Foo(BaseModel): bar: Literal["Bar"] = 'Bar' baz: Literal[None] = None

Environment

  • Pydantic: 2

What Broke

JSON schemas generated from models with Literal types lacked proper type annotations, causing integration issues.

Why It Broke

The JSON schema generation for single item literals did not include type information

Fix Options (Details)

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

pip install pydantic==1.10.15

When NOT to use: This fix should not be applied if backward compatibility with existing JSON schemas is a concern.

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/8944

First fixed release: 1.10.15

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 applied if backward compatibility with existing JSON schemas is a concern.

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

Related Issues

No related fixes found.

Sources

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