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

Proxy env var to prefixed env vars #72

Closed
Kamforka opened this issue Apr 27, 2019 · 2 comments
Closed

Proxy env var to prefixed env vars #72

Kamforka opened this issue Apr 27, 2019 · 2 comments

Comments

@Kamforka
Copy link
Contributor

When I proxy a non-prefixed env var to a prefixed one and try to load them an error is thrown.

Example:

.env

FLASK_ENV=development
APP_ENV={{FLASK_ENV}}

settings.py

from environs import Env

env = Env()
env.read_env()


with env.prefixed('APP_'):
    ENV = env.str('ENV')

Output:

Traceback (most recent call last):
  File "settings.py", line 8, in <module>
    ENV = env.str('ENV')
  File "/.../venv/lib/python3.6/site-packages/environs.py", line 47, in method
    'Environment variable "{}" not set'.format(proxied_key or parsed_key)
environs.EnvError: Environment variable "FLASK_ENV" not set

Is it intentional to only allow proxying variables within the prefix scope?

Obviously there are many possible workarounds to fix the error, however it feels unintuitive to restrict proxying to a prefix scope.

@sloria
Copy link
Owner

sloria commented Apr 27, 2019

This appears to be a bug. I won't have time to look at this soon, so I would definitely review and merge a PR.

@Kamforka
Copy link
Contributor Author

@sloria Got it. I'll make a PR. Took a look at it and seems like a quick fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants