Jump to solution
Verify

The Fix

pip install pydantic==1.10.15

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

Jump to Verify Open PR/Commit
@@ -32,6 +32,7 @@ _build/ .coverage test.py +run_mypy_on_file.py # Documentation files
repro.py
from enum import Enum from pydantic import TypeAdapter class MyEnum(Enum): A = 1 B = 2 ta = TypeAdapter(MyEnum) assert ta.validate_python(1.0) is MyEnum.A assert ta.validate_python(2.0) is MyEnum.B # pydantic=2.6.4 passes validation # pydantic=2.7.1 fails validation # # pydantic_core._pydantic_core.ValidationError: 1 validation error for enum[MyEnum] # Input should be 1, 2 or 3 [type=enum, input_value=1.0, input_type=float] # For further information visit https://errors.pydantic.dev/2.7/v/enum
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: Do not use this fix if your application relies on float values being accepted by enums.\n\nOption B — Safe version pin\npip install pydantic==2.6.4\nWhen NOT to use: Do not use if you need features or security fixes in newer releases.\n\n

Why This Fix Works in Production

  • Trigger: Enum construction from float worked in v2.6.4 but fails in v2.7.1
  • Why the fix works: the upstream fix ships in 1.10.15.

Why This Breaks in Prod

  • Triggered by an upgrade/regression window: 2.7.1 breaks; 1.10.15 is the first fixed release.
  • Production symptom (often without a traceback): Enum construction from float worked in v2.6.4 but fails in v2.7.1

Proof / Evidence

  • GitHub issue: #9375
  • Fix PR: https://github.com/pydantic/pydantic/pull/9064
  • First fixed release: 1.10.15
  • Affected versions: 2.7.1
  • Reproduced locally: No (not executed)
  • Last verified: 2026-02-09
  • Confidence: 0.70
  • Did this fix it?: Yes (upstream fix exists)
  • Own content ratio: 0.59

Discussion

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

“@Idealcoder, Thanks for reporting this. Looks like a regression we should fix in 2.7.2. Adding this to the relevant milestone. Just got back form a…”
@sydney-runkle · 2024-05-14 · source

Failure Signature (Search String)

  • Enum construction from float worked in v2.6.4 but fails in v2.7.1
  • Constructing an enum from a float worked in v2.6.4 but fails in v2.7.1.
Copy-friendly signature
signature.txt
Failure Signature ----------------- Enum construction from float worked in v2.6.4 but fails in v2.7.1 Constructing an enum from a float worked in v2.6.4 but fails in v2.7.1.

Error Message

Signature-only (no traceback captured)
error.txt
Error Message ------------- Enum construction from float worked in v2.6.4 but fails in v2.7.1 Constructing an enum from a float worked in v2.6.4 but fails in v2.7.1.

Minimal Reproduction

repro.py
from enum import Enum from pydantic import TypeAdapter class MyEnum(Enum): A = 1 B = 2 ta = TypeAdapter(MyEnum) assert ta.validate_python(1.0) is MyEnum.A assert ta.validate_python(2.0) is MyEnum.B # pydantic=2.6.4 passes validation # pydantic=2.7.1 fails validation # # pydantic_core._pydantic_core.ValidationError: 1 validation error for enum[MyEnum] # Input should be 1, 2 or 3 [type=enum, input_value=1.0, input_type=float] # For further information visit https://errors.pydantic.dev/2.7/v/enum

Environment

  • Pydantic: 2

What Broke

Users experienced validation errors when passing float values to enums, leading to application crashes.

Fix Options (Details)

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

pip install pydantic==1.10.15

When NOT to use: Do not use this fix if your application relies on float values being accepted by enums.

Use when you can deploy the upstream fix. It is usually lower-risk than long-lived workarounds.

Option B — Safe version pin Backward-compatible pin

pip install pydantic==2.6.4

When NOT to use: Do not use if you need features or security fixes in newer releases.

Use when you can’t upgrade immediately. Plan a follow-up to upgrade (pins can accumulate security/compat debt).

Option D — Guard side-effects with OnceOnly Guardrail for side-effects

Mitigate duplicate external side-effects under retries/timeouts/agent loops by gating the operation before calling external systems.

  • Place OnceOnly between your code/agent and real side-effects (Stripe, emails, CRM, APIs).
  • Use a stable key per side-effect (e.g., customer_id + action + idempotency_key).
  • Fail-safe: configure fail-open vs fail-closed based on blast radius and spend risk.
Show example snippet (optional)
onceonly.py
from onceonly import OnceOnly import os once = OnceOnly(api_key=os.environ["ONCEONLY_API_KEY"], fail_open=True) # Stable idempotency key per real side-effect. # Use a request id / job id / webhook delivery id / Stripe event id, etc. event_id = "evt_..." # replace key = f"stripe:webhook:{event_id}" res = once.check_lock(key=key, ttl=3600) if res.duplicate: return {"status": "already_processed"} # Safe to execute the side-effect exactly once. handle_event(event_id)

See OnceOnly SDK

When NOT to use: Do not use this to hide logic bugs or data corruption. Use it to block duplicate external side-effects and enforce tool permissions/spend caps.

Fix reference: https://github.com/pydantic/pydantic/pull/9064

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

  • Do not use this fix if your application relies on float values being accepted by enums.
  • Do not use if you need features or security fixes in newer releases.
  • Do not use this to hide logic bugs or data corruption. Use it to block duplicate external side-effects and enforce tool permissions/spend caps.

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.6.4 Working
2.7.1 Broken
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.