unstale

pypi / pydantic-settings

pydantic-settings

What changed in pydantic-settings 2, from its official release notes, upgrade guides and advisories. Sources checked 2026-11-30.

22 breaking2 security1 deprecations28 new APIs and options14 behavior and defaults75 fixes and other

See which of these apply to your code, ranked, in your agent:

npx @unstale/cli init

@unstale/cli on npm

pydantic-settings 2142 changes

Breaking changes 22

  • Loading stops with a SettingsError after 10,000 entries.

    2.16.3release notes

  • Secret files that resolve outside secrets_dir are skipped with a warning, preventing links in the directory from making the application load arbitrary readable files.

    2.16.3release notes

  • An explicit secrets_dir on the wrapper now takes precedence over the wrapped source's directory and model config, including when the explicit value is an empty list.

    2.16.2release notes

  • With case_sensitive=False, only registered CLI options are lowercased; arguments after -- and CliUnknownArgs values keep their case.

    2.16.0release notes

  • Each CliUnknownArgs field now receives only leftover arguments from its own subcommand.

    2.16.0release notes

  • An empty JSON array now parses as an empty list instead of [''].

    2.16.0release notes

  • JSON config files are read as UTF-8 by default instead of the locale encoding; this option still overrides it.

    2.16.0release notes

  • With this enabled, a discriminated union default is dropped only when the incoming value selects a different union member.

    2.16.0release notes

  • Python 3.10 is no longer supported; pydantic-settings now requires Python 3.11+.

    2.16.0release notes

  • When false, aliases are ignored in every source; environment variables, secrets, CLI flags and defaults use only field names.

    2.16.0release notes

  • Takes precedence over alias when the two differ, so JSON/YAML/TOML file and CLI values load instead of being silently ignored.

    2.16.0release notes

  • YAML config files are read as UTF-8 by default instead of the locale encoding; this option still overrides it.

    2.16.0release notes

  • The setting now applies to init kwargs and JSON/TOML/YAML config-file sources; because it defaults to False, matching is case-insensitive for these sources. Nested keys remain case-sensitive.

    2.15.0release notes

  • Non-JSON environment values for strict fields now raise ValidationError instead of a less specific error.

    2.15.0release notes

  • Inaccessible secrets now return None.

    2.13.0release notes

  • Python 3.9 is no longer supported.

    2.12.0release notes

  • Environment variables are coerced even when strict is True.

    2.12.0release notes

  • Importing common removed names, or checking them with hasattr() or getattr(), raises an ImportError naming the replacement and linking the migration page; code supporting V1 and V2 should detect the version with try/except ImportError.

    2.0.0upgrade guide

  • The parse_env_var classmethod has been removed; customize settings sources to provide a custom parsing function.

    2.0.0upgrade guide

  • The provider moved from pydantic_ai.providers.google to pydantic_ai.providers.google_gla.

    2.0.0upgrade guide

  • The provider moved from pydantic_ai.providers.google_cloud to pydantic_ai.providers.google_vertex.

    2.0.0upgrade guide

  • BaseSettings moved from pydantic to pydantic-settings; import it from pydantic_settings.

    2.0.0upgrade guide

Security 2

  • With case_sensitive=True, the GCP source skips the list_secrets call, lowering the required IAM permissions to roles/secretmanager.secretAccessor.

    2.15.0release notes

  • The source no longer follows symlinks that point outside secrets_dir.

    2.14.2release notesrelease notessecurity advisory

Deprecations 1

  • Calling result.usage() still works but emits a deprecation warning until V3; result.usage is a property.

    2.0.0upgrade guide

New APIs and options 28

  • Adds an extra for installing the AWS Systems Manager Parameter Store source.

    2.16.0release notes

  • Adds an AWS Systems Manager Parameter Store source that recursively reads parameters under an ssm_path, mapping / onto nested models.

    2.16.0release notes

  • Adds named variadic CLI options that accept multiple values after one option as well as repeated options; required fields need at least one value.

    2.16.0release notes

  • Returns a process-local singleton per settings class; calling the class directly still builds a fresh instance.

    2.16.0release notes

  • Clears the cache used for process-local cached settings instances.

    2.16.0release notes

  • Enables environment variable names to appear in generated CLI help, making --help output useful as configuration documentation.

    2.15.0release notes

  • Set this environment variable to a truthy value with DEBUG logging enabled to inspect source contributions, value precedence, and env-file or secret-file resolution.

    2.15.0release notes

  • Lets you root settings at a nested table in any TOML file, rather than only in pyproject.toml.

    2.15.0release notes

  • JSON, TOML, and YAML file sources accept Traversable resources, allowing packaged configuration files, including files in zip or wheel distributions, to be loaded without casting to Path.

    2.15.0release notes

  • Allows customizing the dotenv setting source to filter variables.

    2.14.0release notes

  • Allows overriding the default help on the CLI internal parser.

    2.13.0release notes

  • Adds support for CLI serialization styles.

    2.13.0release notes

  • Adds CliDualFlag for defining dual CLI flags.

    2.13.0release notes

  • Adds CliToggleFlag for defining toggle-style CLI flags.

    2.13.0release notes

  • Adds the env_prefix_target setting.

    2.13.0release notes

  • Adds format_help method support for the CLI.

    2.13.0release notes

  • Adds the SecretVersion annotation for per-field GCP secret versioning.

    2.13.0release notes

  • AWS Secrets Manager sources support the VersionId parameter for selecting a secret version.

    2.13.0release notes

  • Adds the NestedSecretsSettings source.

    2.12.0release notes

  • Agent accepts output_retries=N to set the output retry budget.

    2.0.0upgrade guide

  • Agent accepts retries as a mapping with output and tools budgets; a bare integer sets both budgets.

    2.0.0upgrade guide

  • Agent specs accept output_retries and tool_retries, and retries as an integer or a mapping with output and tools keys.

    2.0.0upgrade guide

  • Agent accepts tool_retries=N to set the tool retry budget.

    2.0.0upgrade guide

  • Sources can now receive case_sensitive as an argument.

    2.0.0release notes

  • Sources can now receive env_prefix as an argument.

    2.0.0release notes

  • Pydantic Json fields are now supported.

    2.0.0release notes

  • run(), run_sync(), run_stream(), iter(), and override() accept output_retries=N.

    2.0.0upgrade guide

  • run(), run_sync(), run_stream(), iter(), and override() accept retries={'output': N}.

    2.0.0upgrade guide

Behavior and default changes 14

  • Fields with unresolved forward references now emit this warning, which tells you to call model_rebuild(); warning-as-error configurations may turn it into a failure.

    2.15.0release notes

  • The GCP settings source can obtain project_id from an earlier settings source, rather than only from the constructor or GOOGLE_CLOUD_PROJECT.

    2.15.0release notes

  • Supports reading .env files from FIFOs, including those used by 1Password Environments.

    2.14.0release notes

  • The CLI coerces numeric types.

    2.13.0release notes

  • Union discriminator choices are shown in CLI help.

    2.13.0release notes

  • The CLI help message no longer includes the default value for CliToggleFlag.

    2.13.0release notes

  • Config file sources support deep merging, allowing nested configuration values from multiple sources to be combined.

    2.13.0release notes

  • File sources accept non-Path files, such as Traversable objects, and open files using Path.open.

    2.13.0release notes

  • yaml_config_section supports nested paths.

    2.13.0release notes

  • Enum values support kebab case.

    2.12.0release notes

  • Non-explicit default values are stripped.

    2.12.0release notes

  • Settings sources follow the order init > env > dotenv > secrets > defaults.

    2.12.0release notes

  • SettingsConfigDict is now public, so developers can import and use it directly.

    2.0.0release notes

  • Source class initialization parameters now have default values, allowing initialization without supplying every parameter.

    2.0.0release notes

Fixes and other changes 75

  • Serialization keeps each level's CliUnknownArgs before that level's subcommand token, so parsing the output again no longer moves a parent's unknown args onto the subcommand.

    2.16.3release notes

  • Hidden entries (names starting with .) are skipped again, restoring the behavior from before 2.14.2.

    2.16.3release notes

  • With secrets_nested_subdir=True, directories reached through a second symlink are loaded again, fixing lost nested secrets in layouts such as Kubernetes secret volumes.

    2.16.3release notes

  • Symlink loops inside secrets_dir are skipped instead of aborting the load with RuntimeError on Python 3.11 and 3.12.

    2.16.3release notes

  • CliApp.run now rebuilds AliasPath inputs for BaseModel and pydantic dataclass commands, respects AliasChoices priority, and leaves unsupplied path defaults to the model.

    2.16.2release notes

  • A stdlib dataclass default on a discriminated union field no longer raises NameError when another dataclass field has a string annotation naming a local class.

    2.16.2release notes

  • Dictionary values typed as unions now JSON-decode nested environment values; only arrays and objects are decoded, and decoding follows enable_decoding and the field's NoDecode/ForceDecode.

    2.16.2release notes

  • Inner discriminated unions declared with Annotated and Field(discriminator=...) are now detected; when an incoming tag selects another member, default fields are no longer merged into it.

    2.16.2release notes

  • Fixed-length tuple positionals and NamedTuples are single-valued again; variable-length tuples remain variadic.

    2.16.1release notes

  • A field typed as an alias of a list of dicts accepts a JSON list again instead of merging its objects into one dict.

    2.16.1release notes

  • A bare single-segment AliasPath no longer tries to JSON-decode plain string values.

    2.16.0release notes

  • Resolving a named Annotated type alias no longer mutates shared FieldInfo metadata, avoiding validators running twice on subclasses or after model_rebuild().

    2.16.0release notes

  • Case-insensitive matching now works for nested pydantic dataclasses.

    2.16.0release notes

  • Tuples, frozenset, MutableSequence and other collection subtypes, including named collection type aliases, are treated as repeatable or variadic options.

    2.16.0release notes

  • cli_exit_on_error=False is now honored by CliSubCommand parsers, which raise SettingsError instead of exiting.

    2.16.0release notes

  • No longer crashes when cli_prefix is set in model_config.

    2.16.0release notes

  • Serialized output now round-trips through CliApp.run for enums, tuples, dates, Decimal values, explicit None, empty containers, CliVariadicArg values, and populated CliUnknownArgs fields.

    2.16.0release notes

  • Serialization now preserves explicit None values.

    2.16.0release notes

  • Serialization now preserves empty containers.

    2.16.0release notes

  • Serialization now handles populated CliUnknownArgs fields without raising IndexError.

    2.16.0release notes

  • Serialized CLI output now parses for enums, tuples, dates and Decimal values.

    2.16.0release notes

  • Serialization now preserves CliVariadicArg values.

    2.16.0release notes

  • Aliases keep their case when case_sensitive=False.

    2.16.0release notes

  • Set, MutableSet and AbstractSet fields now JSON-decode environment values.

    2.16.0release notes

  • dash_to_underscore=True now works for nested Azure Key Vault model fields.

    2.16.0release notes

  • DotenvFiltering is now exported from pydantic_settings.sources.types.

    2.16.0release notes

  • A bare typing.Dict field no longer raises IndexError when env_nested_delimiter is set.

    2.16.0release notes

  • Azure Key Vault and GCP Secret Manager now honor env_parse_none_str.

    2.16.0release notes

  • With extra='allow', a non-lowercase env_prefix is now stripped from dotenv extras.

    2.16.0release notes

  • An empty JSON config file is treated as an empty mapping instead of crashing.

    2.16.0release notes

  • Named union type aliases now decode like inline equivalents in environment and dotenv sources, including under Optional, Annotated and custom validation aliases.

    2.16.0release notes

  • The source now validates its specific constructor arguments.

    2.16.0release notes

  • Adds support for pydantic 2.14, including fixes for CliApp.run and validate_by_alias=False handling.

    2.16.0release notes

  • Adds support for Python 3.15.

    2.16.0release notes

  • secrets_case_sensitive=True is now honored on Windows.

    2.16.0release notes

  • An explicit empty tuple overrides the model config to read the TOML file root.

    2.16.0release notes

  • Home-directory paths are expanded when checking whether the TOML table-header file exists.

    2.16.0release notes

  • Environment values for nested model fields using AliasPath are now JSON-decoded.

    2.15.0release notes

  • Environment variables now load on Windows when case_sensitive=True, despite os.environ keys being upper-cased.

    2.15.0release notes

  • Dotenv extras are no longer wrongly claimed by a complex field that shares their name prefix.

    2.15.0release notes

  • Enum names now parse through nested annotations such as Optional[Annotated[MyEnum, ...]] when enum parsing is enabled.

    2.15.0release notes

  • Case-insensitive field matching now works for optional nested models.

    2.15.0release notes

  • Secret subclasses no longer crash when loaded from the environment.

    2.15.0release notes

  • Secret files are now read as UTF-8 rather than using the platform locale encoding, avoiding corruption of non-ASCII secrets on some Windows code pages.

    2.15.0release notes

  • This package is no longer required at runtime.

    2.15.0release notes

  • An empty section now falls back to defaults instead of raising an AttributeError.

    2.15.0release notes

  • Fixes conflicts between a field named cls and a classmethod parameter.

    2.14.1release notes

  • Fixes AliasChoices being ignored when provider priority changes.

    2.14.0release notes

  • Fixes a RecursionError when CLI handles mutually recursive models.

    2.14.0release notes

  • Preserves CLI descriptions under python -OO by falling back to json_schema_extra.

    2.14.0release notes

  • Fixes cli_ignore_unknown_args=True not working on subcommands.

    2.14.0release notes

  • Fixes env_file from model_config being ignored when running CliApp.

    2.14.0release notes

  • Fixes a crash for CliPositionalArg[list[CustomType]].

    2.14.0release notes

  • Fixes parsing environment variables into Optional Strict types.

    2.14.0release notes

  • Fixes coercion of Literal[numeric Enum] values for CLI and environment variables.

    2.14.0release notes

  • Ensures environment and CLI providers discover nested discriminated unions.

    2.14.0release notes

  • Resolves a KeyError for underscore field names in run_subcommand.

    2.14.0release notes

  • Fixes CLI recognition of field names when validate_by_name and AliasChoices are used.

    2.14.0release notes

  • Fixes a regression affecting bool fields introduced in 2.13.0.

    2.13.1release notes

  • Fixes a RecursionError with self-referential models in CliApp.

    2.13.1release notes

  • Fixes an AttributeError when nested environment variables are used with dict fields.

    2.13.1release notes

  • Fixes JSON decoding for parameterized PEP 695 type aliases.

    2.13.1release notes

  • Fixes CLI parsing errors for set field types introduced in 2.13.0.

    2.13.1release notes

  • Allows snake_case_conversion to be used with env_prefix for the Azure Key Vault source.

    2.13.0release notes

  • Fixes handling of duplicate enum field values in the CLI.

    2.13.0release notes

  • Fixes handling of CliImplicitFlag[bool] when cli_kebab_case="all".

    2.13.0release notes

  • Fixes loading nested configuration from environment variables.

    2.13.0release notes

  • Fixes handling of external list arguments in the CLI.

    2.13.0release notes

  • Fixes case-insensitive retrieval in the Google Secret Manager settings source.

    2.13.0release notes

  • Restoring init kwargs now uses a deterministic order.

    2.13.0release notes

  • Avoids conflicts with the NAME environment variable in WSL.

    2.13.0release notes

  • Type aliases are unpacked when looking for NoDecode, so the annotation is recognized through aliases.

    2.13.0release notes

  • Only overrides preferred_key when no value was found.

    2.13.0release notes

  • Init kwarg names are restored before the final state dictionary is returned.

    2.12.0release notes

  • Adds support for Python 3.14.

    2.12.0release notes