The Fix
pip install pydantic==1.10.15
Based on closed pydantic/pydantic issue #8942 · 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%.
@@ -54,7 +54,7 @@
from .annotated_handlers import GetJsonSchemaHandler
from .config import JsonDict, JsonSchemaExtraCallable, JsonValue
-from .errors import PydanticInvalidForJsonSchema, PydanticUserError
+from .errors import PydanticInvalidForJsonSchema, PydanticSchemaGenerationError, PydanticUserError
@pytest.mark.parametrize('ip_address', (IPv4Address('127.0.0.1'), (IPv6Address('::1'))))
def test_ipv4_address_parsing(ip_address):
class IpModel(BaseModel):
ip: IPvAnyAddress = ip_address
print(IpModel.model_json_schema())
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==1.10.15\nWhen NOT to use: This fix should not be used if the serialization of other non-implemented types is required.\n\n
Why This Fix Works in Production
- Trigger: PydanticJsonSchemaWarning: Default value 127.0.0.1 is not JSON serializable; excluding default from JSON schema [non-serializable-default]
- Mechanism: The type `IPv4Address` was not being serialized correctly in Pydantic V2
- Why the fix works: Fixes a bug where default values of model fields won't be serialized into the JSON schema. (first fixed release: 1.10.15).
- 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 type `IPv4Address` was not being serialized correctly in Pydantic V2
- Production symptom (often without a traceback): PydanticJsonSchemaWarning: Default value 127.0.0.1 is not JSON serializable; excluding default from JSON schema [non-serializable-default]
Proof / Evidence
- GitHub issue: #8942
- Fix PR: https://github.com/pydantic/pydantic/pull/9066
- First fixed release: 1.10.15
- 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.62
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“@sydney-runkle I'd like to work on this if it's still available 😄”
“I think as IPv4Address is so far handled just in pydantic, I think it'd be better to keep the change out of core for now”
“@Kyomotoi, Thanks for the report. This should be relatively easy to fix. I'll note - this can't be solved with validate_default=True.”
“@NeevCohen, Great job looking into this. Let's see what @davidhewitt thinks first thing tomorrow morning :).”
Failure Signature (Search String)
- PydanticJsonSchemaWarning: Default value 127.0.0.1 is not JSON serializable; excluding default from JSON schema [non-serializable-default]
- warnings.warn(message, PydanticJsonSchemaWarning)
Copy-friendly signature
Failure Signature
-----------------
PydanticJsonSchemaWarning: Default value 127.0.0.1 is not JSON serializable; excluding default from JSON schema [non-serializable-default]
warnings.warn(message, PydanticJsonSchemaWarning)
Error Message
Signature-only (no traceback captured)
Error Message
-------------
PydanticJsonSchemaWarning: Default value 127.0.0.1 is not JSON serializable; excluding default from JSON schema [non-serializable-default]
warnings.warn(message, PydanticJsonSchemaWarning)
Minimal Reproduction
@pytest.mark.parametrize('ip_address', (IPv4Address('127.0.0.1'), (IPv6Address('::1'))))
def test_ipv4_address_parsing(ip_address):
class IpModel(BaseModel):
ip: IPvAnyAddress = ip_address
print(IpModel.model_json_schema())
Environment
- Python: 3.11
- Pydantic: 2
What Broke
Users received warnings about non-serializable default values in JSON schema.
Why It Broke
The type `IPv4Address` was not being serialized correctly in Pydantic V2
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install pydantic==1.10.15
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/9066
First fixed release: 1.10.15
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- This fix should not be used if the serialization of other non-implemented types is required.
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 |
|---|---|
| 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.