-
-
Notifications
You must be signed in to change notification settings - Fork 89
env_prefix prevents env_file from working #215
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
Comments
Thanks @red8888 for reporting this. Agree, that is probably a bug. |
Hi @hramezani |
Thanks @kjithin, I've assigned it to you! |
…Source when env_prefix is specified The current implementation in DotEnvSettingsSource allows non-prefixed variables even when extra='forbid'(default) is set . This commit addresses the issue by raising a SettingsError when extra is set to 'forbid' and variables are encountered without using the specified prefix.
Thanks @hramezani. I've submitted a pull request addressing this issue. Kindly review and share your feedback. |
Uh oh!
There was an error while loading. Please reload this page.
Initial Checks
Description
Assuming this is a bug because I found nothing in the docs explaining this behavior.
Spent forever trying to understand why env_file wasn't working. Commenting out env_prefix cause env_file to start working. This can't be by design right? I should be able to define both.
Example Code
Python, Pydantic & OS Version
Edit
I found the issue. The issue is that setting
env_prefix
causes pydantic to ignore non-prefixed env vars defined in you dotenv files.I was expecting it to fail because I had un-prefixed vars defined in mysettings.env for example:
Changing those to this worked:
So I think the bug is pydantic should not be ignoring un-prefixed fields in dotenv files.
Because while this correctly throws
Extra inputs are not permitted
:This throws no errors at all:
The text was updated successfully, but these errors were encountered: