-
-
Notifications
You must be signed in to change notification settings - Fork 66
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
Pydantic Settings env_prefix is applying to secrets filenames #508
Comments
This is an intended behavior. I agree that the |
Cool, for now then can I suggest updating the https://docs.pydantic.dev/latest/concepts/pydantic_settings/#environment-variable-names section in the docs to something along the lines of "Setting Name Prefixes" and update the text? Then, consider if it would be worth it to create a new name and alias the old one to it, then deprecate the old one? The key for me is that I read the documentation and was surprised by the actual behavior, so if the documentation is updated, I don't think it is hard to work around it. I just wasn't sure it was intentional or not :) Oh, and thank you @hramezani for your contributions to Django and Pydantic, I use both of these tools extensively! Your contributions are very appreciated! |
Agree, we need to update the document here.
Would be a good idea. probably I work on it later.
Thanks for your message. it worth a lot to me ❤️ |
@ensignavenger I faced the same problem and ended up writing a separate settings source for secrets: https://github.com/makukha/pydantic-file-secrets |
I merged a PR to improve on |
Initial Checks
Description
The documentation for Pydantic Settings states the env_prefix applies to environment variables. However, it is also applying to secret filenames. See https://docs.pydantic.dev/latest/concepts/pydantic_settings/#validation-of-default-values
I think it makes more sense to have env_prefix only applies to environment vars, as is reflected in the documentation, so I would think this is a code bug, but if the behavior is intended, the documentation should reflect that.
Example Code
Python, Pydantic & OS Version
The text was updated successfully, but these errors were encountered: