The Fix
pip install pydantic==2.10.3
Based on closed pydantic/pydantic issue #11019 · PR/commit linked
@@ -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
from fastapi import FastAPI
from pydantic import HttpUrl
app = FastAPI()
@app.get("/")
async def root() -> HttpUrl:
return HttpUrl(url="https://www.example.com")
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==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).
- 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
- GitHub issue: #11019
- Fix PR: https://github.com/pydantic/pydantic/pull/11035
- First fixed release: 2.10.3
- 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
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
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.”
“As I said on private to @sydney-runkle , the problem is on mode='serialization'.”
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
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 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
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
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.
When NOT to Use This Fix
- Do not apply this fix if you require the previous behavior of omitting constraints intentionally.
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 |
|---|---|
| 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.