The Fix
Fixes the handling of empty string aliases in the AliasGenerator, allowing them to be used correctly.
Based on closed pydantic/pydantic issue #8808 · PR/commit linked
@@ -296,6 +296,15 @@ def push(self, for_type: type[Any]):
+def _get_first_non_null(a: Any, b: Any) -> Any:
+ """Return the first argument if it is not None, otherwise return the second argument.
+
Option A — Apply the official fix\nFixes the handling of empty string aliases in the AliasGenerator, allowing them to be used correctly.\nWhen NOT to use: This fix should not be applied if the application relies on the previous behavior of ignoring empty string aliases.\n\n
Why This Fix Works in Production
- Trigger: Users experienced incorrect alias generation when empty string aliases were specified.
- Mechanism: The handling of empty string aliases in the AliasGenerator was incorrect, causing unexpected behavior
Why This Breaks in Prod
- The handling of empty string aliases in the AliasGenerator was incorrect, causing unexpected behavior
- Production symptom (often without a traceback): Users experienced incorrect alias generation when empty string aliases were specified.
Proof / Evidence
- GitHub issue: #8808
- Fix PR: https://github.com/pydantic/pydantic/pull/8810
- Reproduced locally: No (not executed)
- Last verified: 2026-02-12
- Confidence: 0.60
- Did this fix it?: Yes (upstream fix exists)
- Own content ratio: 0.80
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“See https://github.com/pydantic/pydantic/pull/8806#discussion_r1488616617 for more details”
Failure Signature (Search String)
- Users experienced incorrect alias generation when empty string aliases were specified.
Copy-friendly signature
Failure Signature
-----------------
Users experienced incorrect alias generation when empty string aliases were specified.
Error Message
Signature-only (no traceback captured)
Error Message
-------------
Users experienced incorrect alias generation when empty string aliases were specified.
What Broke
Users experienced incorrect alias generation when empty string aliases were specified.
Why It Broke
The handling of empty string aliases in the AliasGenerator was incorrect, causing unexpected behavior
Fix Options (Details)
Option A — Apply the official fix
Fixes the handling of empty string aliases in the AliasGenerator, allowing them to be used correctly.
Fix reference: https://github.com/pydantic/pydantic/pull/8810
Last verified: 2026-02-12. Validate in your environment.
When NOT to Use This Fix
- This fix should not be applied if the application relies on the previous behavior of ignoring empty string aliases.
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.
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.