Migrating to Pydantic v2.12.4
Version v2.12.4 introduces 1 breaking change. This guide details how to update your code.
Released: 11/5/2025
⚠️ Check Your Code
If you use any of these symbols, you need to read this guide:
AnyUrlAnyUrl.buildDsnDsn.buildTypedDictserialize_as_anycollections.defaultdictexclude_ifBreaking Changes
●Issue #1
The behavior of percent-encoding credentials in the build() method for AnyUrl and Dsn types has been reverted to match previous versions.
✓Solution
If you relied on the previous behavior (which was present briefly in 2.12.x before this patch), you might need to adjust your URL construction logic. The next release will introduce an opt-in option for this encoding.
Migration Steps
- 1Update your Pydantic dependency to version 2.12.4 or later.
- 2If you were using `AnyUrl` or `Dsn` and noticed unexpected percent-encoding of credentials in constructed URLs, be aware that this behavior has been reverted. Verify that your application now behaves as expected based on pre-2.12.4 behavior.
- 3If you are using Python 3.14 or greater, ensure that any complex validation involving parent `TypedDict` classes with forward references is now working correctly.
- 4If you are using `collections.defaultdict` in your models, verify that default values are not being unexpectedly accessed during validation, as a subtle regression has been fixed.
Release Summary
A patch release fixing regressions in URL building, defaultdict validation, and TypedDict forward references, while improving IP address serialization under serialize_as_any.
Need More Details?
View the full release notes and all changes for Pydantic v2.12.4.
View Full Changelog