Jump to solution
Verify

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%.

Jump to Verify Open PR/Commit
@@ -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
repro.py
@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())
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 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).
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

  • 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

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 😄”
@NeevCohen · 2024-03-04 · source
“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”
@davidhewitt · 2024-03-19 · source
“@Kyomotoi, Thanks for the report. This should be relatively easy to fix. I'll note - this can't be solved with validate_default=True.”
@sydney-runkle · 2024-03-04 · source
“@NeevCohen, Great job looking into this. Let's see what @davidhewitt thinks first thing tomorrow morning :).”
@sydney-runkle · 2024-03-19 · source

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
signature.txt
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.txt
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

repro.py
@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

When NOT to use: This fix should not be used if the serialization of other non-implemented types is required.

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.

Get updates

We publish verified fixes weekly. No spam.

Subscribe

When NOT to Use This Fix

  • This fix should not be used if the serialization of other non-implemented types is required.

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.