Jump to solution
Verify

The Fix

pip install pydantic==2.8.1

Based on closed pydantic/pydantic issue #9811 · 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
@@ -49,13 +49,14 @@ def to_snake(camel: str) -> str: The converted string in snake_case. """ - # `(?<=[a-zA-Z])(?=[0-9])` matches the space between a letter and a digit - # `(?<=[a-z0-9])(?=[A-Z])` matches the space between a lowercase letter / digit and uppercase letter - # `(?<=[A-Z])(?=[A-Z][a-z])` matches the space between two uppercase letters when the latter is followed by a lowercase letter
repro.py
from pydantic.alias_generators import to_snake pascal_case_string = "SomethingV2" to_snake(pascal_case_string) # returns "something_v_2" when "something_v2" is expected
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==2.8.1\nWhen NOT to use: Do not use this fix if the behavior of `to_snake` needs to remain unchanged for specific use cases.\n\n

Why This Fix Works in Production

  • Trigger: We've noticed a change of behaviour in pydantic v2.8, released today, that we think is an unintended change.
  • Mechanism: The `to_snake` function incorrectly handles uppercase letters in versioned class names
  • Why the fix works: Fixes a breaking change in the `to_snake` function introduced in Pydantic v2.8. (first fixed release: 2.8.1).
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 `to_snake` function incorrectly handles uppercase letters in versioned class names
  • Production symptom (often without a traceback): We've noticed a change of behaviour in pydantic v2.8, released today, that we think is an unintended change.

Proof / Evidence

Discussion

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

“@simonarcher99, Thanks for reporting this! Sorry about that. Looks like I broke this in https://github.com/pydantic/pydantic/pull/9561. I think this is something we want to fix.”
@sydney-runkle · 2024-07-01 · source
“Fixed via the above PR, you can pull from main for the fix now, and we'll release v2.8.1 later this week!”
@sydney-runkle · 2024-07-01 · source

Failure Signature (Search String)

  • We've noticed a change of behaviour in pydantic v2.8, released today, that we think is an unintended change.
Copy-friendly signature
signature.txt
Failure Signature ----------------- We've noticed a change of behaviour in pydantic v2.8, released today, that we think is an unintended change. python version: 3.11.9 (main, May 29 2024, 12:45:38) [Clang 15.0.0 (clang-1500.3.9.4)]

Error Message

Signature-only (no traceback captured)
error.txt
Error Message ------------- We've noticed a change of behaviour in pydantic v2.8, released today, that we think is an unintended change. python version: 3.11.9 (main, May 29 2024, 12:45:38) [Clang 15.0.0 (clang-1500.3.9.4)]

Minimal Reproduction

repro.py
from pydantic.alias_generators import to_snake pascal_case_string = "SomethingV2" to_snake(pascal_case_string) # returns "something_v_2" when "something_v2" is expected

Environment

  • Python: 3.11
  • Pydantic: 2.8

What Broke

The function returns incorrect output for PascalCase strings, leading to potential data inconsistencies.

Why It Broke

The `to_snake` function incorrectly handles uppercase letters in versioned class names

Fix Options (Details)

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

pip install pydantic==2.8.1

When NOT to use: Do not use this fix if the behavior of `to_snake` needs to remain unchanged for specific use cases.

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/9812

First fixed release: 2.8.1

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 the behavior of `to_snake` needs to remain unchanged for specific use cases.

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.8.1 Fixed

Related Issues

No related fixes found.

Sources

We don’t republish the full GitHub discussion text. Use the links above for context.