Jump to solution
Verify

The Fix

pip install pydantic==2.10.3

Based on closed pydantic/pydantic issue #11019 · PR/commit linked

Jump to Verify Open PR/Commit
@@ -288,6 +288,15 @@ def wrap_val(v, h): ) + @classmethod + def __get_pydantic_json_schema__( + cls, core_schema: core_schema.CoreSchema, handler: _schema_generation_shared.GetJsonSchemaHandler
repro.py
from fastapi import FastAPI from pydantic import HttpUrl app = FastAPI() @app.get("/") async def root() -> HttpUrl: return HttpUrl(url="https://www.example.com")
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==2.10.3\nWhen NOT to use: Do not apply this fix if you require the previous behavior of omitting constraints intentionally.\n\n

Why This Fix Works in Production

  • Trigger: v2.10.x: OpenAPI schema generation omits constraints for HttpUrl
  • Mechanism: Fixes the omission of constraints for HttpUrl in OpenAPI schema generation in Pydantic 2.10.
  • Why the fix works: Fixes the omission of constraints for HttpUrl in OpenAPI schema generation in Pydantic 2.10. (first fixed release: 2.10.3).
Production impact:
  • If left unfixed, this can cause silent data inconsistencies that propagate (bad cache entries, incorrect downstream decisions).

Why This Breaks in Prod

  • Shows up under Python 3.12 in real deployments (not just unit tests).
  • Production symptom (often without a traceback): v2.10.x: OpenAPI schema generation omits constraints for HttpUrl

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

Discussion

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

“Interesting: I'm able to repro your issue with FastAPI. We're looking into this.”
@sydney-runkle · 2024-12-02 · repro detail · source
“As I said on private to @sydney-runkle , the problem is on mode='serialization'.”
@Kludex · 2024-12-03 · source

Failure Signature (Search String)

  • v2.10.x: OpenAPI schema generation omits constraints for HttpUrl
  • Starting with Pydantic 2.10 we have noticed that FastAPI's OpenAPI schema export has changed for HttpUrl types.
Copy-friendly signature
signature.txt
Failure Signature ----------------- v2.10.x: OpenAPI schema generation omits constraints for HttpUrl Starting with Pydantic 2.10 we have noticed that FastAPI's OpenAPI schema export has changed for HttpUrl types.

Error Message

Signature-only (no traceback captured)
error.txt
Error Message ------------- v2.10.x: OpenAPI schema generation omits constraints for HttpUrl Starting with Pydantic 2.10 we have noticed that FastAPI's OpenAPI schema export has changed for HttpUrl types.

Minimal Reproduction

repro.py
from fastapi import FastAPI from pydantic import HttpUrl app = FastAPI() @app.get("/") async def root() -> HttpUrl: return HttpUrl(url="https://www.example.com")

Environment

  • Python: 3.12
  • Pydantic: 2

What Broke

OpenAPI schema lacks necessary constraints, leading to potential validation issues in FastAPI applications.

Fix Options (Details)

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

pip install pydantic==2.10.3

When NOT to use: Do not apply this fix if you require the previous behavior of omitting constraints intentionally.

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

First fixed release: 2.10.3

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

  • Do not apply this fix if you require the previous behavior of omitting constraints intentionally.

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
2.10.3 Fixed

Related Issues

No related fixes found.

Sources

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