Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested field names containing underscore can no longer be parsed from env #451

Closed
WieslerAA opened this issue Oct 21, 2024 · 2 comments
Closed
Assignees
Labels
duplicate This issue or pull request already exists

Comments

@WieslerAA
Copy link

WieslerAA commented Oct 21, 2024

Example settings that worked before 2.6.0:

from pydantic_settings import BaseSettings, SettingsConfigDict

os.setenv("INNER_TEST_STR", "abc")

class Inner(BaseSettings):
    model_config = SettingsConfigDict(env_prefix="INNER_")
    test_str: str

class Settings(BaseSettings):
    inner: Inner

This can't be done any more. The env_prefix of Inner is completely ignored, since there is no env variable for inner.

Note that I also can't use the env separator _ since then the env variable is parsed as inner.test.str which is wrong.

@WieslerAA WieslerAA changed the title Names containing underscore can no longer be parsed from env Field names containing underscore can no longer be parsed from env Oct 21, 2024
@WieslerAA WieslerAA changed the title Field names containing underscore can no longer be parsed from env Nested field names containing underscore can no longer be parsed from env Oct 21, 2024
@hramezani
Copy link
Member

hramezani commented Oct 21, 2024

Thanks for reporting this.

It is a duplicate of #447

@hramezani hramezani added duplicate This issue or pull request already exists and removed unconfirmed labels Oct 21, 2024
@hramezani
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants