Open rra opened 1 week ago
I should have added explicitly that this doesn't work in pydantic-settings 2.5.2 if, in the example, GitHubConfig
inherits from BaseModel
instead. That results in the following error:
github.GITHUB_CLIENT_SECRET
Field required [type=missing, input_value={'client_id': 'client-id'}, input_type=dict]
For further information visit https://errors.pydantic.dev/2.9/v/missing
We are (in a pretty large number of places) intentionally using the pre-2.6 behavior of submodels that inherit from
BaseSettings
instead ofBaseModel
as a way to use environment variables to configure those portions of the settings directly without having to use the more complex convention for environment variables that specify the full path down to the field. This allows us to use standardized environment variables for that specific block of settings, regardless of what application settings they're embedded in.For example, this code works as desired with pydantic-settings 2.5.2, but breaks with 2.6.0:
With pydantic-settings 2.6.0, it produces the following error:
We use this configuration pattern very heavily for Kubernetes applications, since most of the application configuration is injected from the
values.yaml
file as YAML, but secrets, which have to come from Kubernetes secrets, are then injected via environment variables.I think this may partially duplicate other issues (specifically #447 and #445), but the descriptions there aren't quite the same and involve more complex functionality that we weren't using, so I thought the separate report may still be useful.