The Fix
pip install pydantic==2.10.3
Based on closed pydantic/pydantic issue #10968 · 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%.
@@ -456,13 +456,13 @@ class AnyUrl(_BaseUrl):
* Any scheme allowed
* Top-level domain (TLD) not required
- * Host required
+ * Host not required
pydantic version: 2.10.1
pydantic-core version: 2.27.1
pydantic-core build: profile=release pgo=false
install path: /private/tmp/pyd/venv/lib/python3.12/site-packages/pydantic
python version: 3.12.7 (main, Oct 1 2024, 02:05:46) [Clang 15.0.0 (clang-1500.3.9.4)]
platform: macOS-15.1-arm64-arm-64bit
related packages: pydantic-settings-2.6.1 typing_extensions-4.12.2
commit: unknown
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 use this fix if you require strict host validation for URLs.\n\n
Why This Fix Works in Production
- Trigger: pydantic_core._pydantic_core.ValidationError: 1 validation error for function-wrap[wrap_val()]
- Mechanism: Fixes the enforcement of host requirement for URLs in AnyUrl to be compatible with v2.9 behavior.
- Why the fix works: Fixes the enforcement of host requirement for URLs in AnyUrl to be compatible with v2.9 behavior. (first fixed release: 2.10.3).
- 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.12 in real deployments (not just unit tests).
- Surfaces as: pydantic_core._pydantic_core.ValidationError: 1 validation error for function-wrap[wrap_val()]
Proof / Evidence
- GitHub issue: #10968
- Fix PR: https://github.com/pydantic/pydantic/pull/11027
- 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.49
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“AnyUrl doesn't allow localhost as host in v2.10.2: file://localhost/dir/file.suffix should be valid though, right?”
“Hi! I believe this is better behavior - AnyUrl documentation suggested (even in v2.9.2) that a host was required, and now that is enforced. Let…”
“Alright, we'll fix this for v2.10.2. Thanks for bringing this to our attention!”
Failure Signature (Search String)
- pydantic_core._pydantic_core.ValidationError: 1 validation error for function-wrap[wrap_val()]
Error Message
Stack trace
Error Message
-------------
pydantic_core._pydantic_core.ValidationError: 1 validation error for function-wrap[wrap_val()]
Input should be a valid URL, empty host [type=url_parsing, input_value='data:image/png;base64,iV...Y4OHwAAAABJRU5ErkJggg==', input_type=str]
Minimal Reproduction
pydantic version: 2.10.1
pydantic-core version: 2.27.1
pydantic-core build: profile=release pgo=false
install path: /private/tmp/pyd/venv/lib/python3.12/site-packages/pydantic
python version: 3.12.7 (main, Oct 1 2024, 02:05:46) [Clang 15.0.0 (clang-1500.3.9.4)]
platform: macOS-15.1-arm64-arm-64bit
related packages: pydantic-settings-2.6.1 typing_extensions-4.12.2
commit: unknown
Environment
- Python: 3.12
- Pydantic: 2
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/11027
First fixed release: 2.10.3
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- Do not use this fix if you require strict host validation for URLs.
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.