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%.
@@ -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
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
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.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).
- 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
- GitHub issue: #9811
- Fix PR: https://github.com/pydantic/pydantic/pull/9812
- First fixed release: 2.8.1
- Reproduced locally: No (not executed)
- Last verified: 2026-02-09
- Confidence: 0.75
- Did this fix it?: Yes (upstream fix exists)
- Own content ratio: 0.60
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.”
“Fixed via the above PR, you can pull from main for the fix now, and we'll release v2.8.1 later this week!”
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
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 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
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
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.
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
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.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.