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

interpolate flag functionality is not implemented #415

Closed
r4victor opened this issue Sep 2, 2022 · 6 comments
Closed

interpolate flag functionality is not implemented #415

r4victor opened this issue Sep 2, 2022 · 6 comments
Assignees
Labels
enhancement New feature or request

Comments

@r4victor
Copy link

r4victor commented Sep 2, 2022

I did SECRET_KEY = env('DJANGO_SECRET_KEY') and got the error:

django.core.exceptions.ImproperlyConfigured: Set the a&d3*0k#skh)!5o)$))zz9&%hr@-akid5zh--05ei790+wn0$r environment variable

This is becuase my DJANGO_SECRET_KEY starts with the dollar sign:

DJANGO_SECRET_KEY="$a&d3*0k#skh)!5o)$))zz9&%hr@-akid5zh--05ei790+wn0$r"

There was a number of issues for this problem: #284, #60, #271.

Eventually, #333 somewhat solved the issue by allowing to escape the dollar sign. But this is not the best approach for generated values such as secret keys. The better option would be an ability to disable interpolation altogether. Ideally by default since the behaviour is unexpected.

Interestingly, the interpolation flag is described in the docs: https://django-environ.readthedocs.io/en/latest/tips.html?highlight=Proxied%20Values#proxy-value. BUT it's not implemented! This commit introduced the doc. Apparently, the implementation (#145) was not merged and closed in favor of #333. I don't know why. #145 seems like a proper solution.

@ebridges
Copy link

It does appear to work albeit in a limited fashion, e.g. here's the example from the docs, plus the use case I'm looking for (embedding db credentials into a db url). The example from the docs works but the URL case does not. Given that the word interpolate only occurs in the documentation in the code base, it seems that it's relying on some kind of implicit behavior.

import environ

TEST_ENV='test.env'

with open(TEST_ENV, 'w') as f:
    f.write('FOO=bar\n')
    f.write('BAR=$FOO\n')
    f.write('URL=abc://$FOO\n')

env = environ.Env(interpolate=True)
env.read_env(TEST_ENV)

bar = env('BAR')
url = env('URL')

print(f'bar: {bar}, url: {url}')

@r4victor
Copy link
Author

@ebridges, interpolate=True seems to work because interpolation is a default behaviour. Try calling environ.Env() or environ.Env(interpolate=False) and you'll get the same result.

@ebridges
Copy link

Yes I agree. Because I needed this functionality I have simply switched to use python-dotenv which offers that.

David-Wobrock added a commit to David-Wobrock/django-environ that referenced this issue Sep 26, 2022
The argument is already documented but not implemented yet.
Fixes joke2k#415
David-Wobrock added a commit to David-Wobrock/django-environ that referenced this issue Sep 26, 2022
The argument is already documented but not implemented yet.
Fixes joke2k#415
@ThalusA
Copy link

ThalusA commented Dec 17, 2022

This feature will really be never implemented ?

@sergeyklay sergeyklay added the enhancement New feature or request label Mar 1, 2023
@daggaz
Copy link

daggaz commented Jul 10, 2023

This one just tripped me up too. Any chance the attached PR will be merged soon? In my case, I'm generating and setting a django secret key, and it ended up randomly starting with $, which caused me bit of confusion...

David-Wobrock added a commit to David-Wobrock/django-environ that referenced this issue Jul 10, 2023
The argument is already documented but not implemented yet.
Fixes joke2k#415
David-Wobrock added a commit to David-Wobrock/django-environ that referenced this issue Jul 14, 2023
The argument is already documented but not implemented yet.
Fixes joke2k#415
David-Wobrock added a commit to David-Wobrock/django-environ that referenced this issue Jul 14, 2023
The argument is already documented but not implemented yet.
Fixes joke2k#415
sergeyklay pushed a commit that referenced this issue Jul 17, 2023
The argument is already documented but not implemented yet.
Fixes #415
@sergeyklay sergeyklay self-assigned this Aug 30, 2023
@sergeyklay
Copy link
Collaborator

This is implemented in #419. Thank you for the report.

David-Wobrock added a commit to David-Wobrock/django-environ that referenced this issue Sep 5, 2023
The argument is already documented but not implemented yet.
Fixes joke2k#415
David-Wobrock added a commit to David-Wobrock/django-environ that referenced this issue Sep 5, 2023
The argument is already documented but not implemented yet.
Fixes joke2k#415
David-Wobrock added a commit to David-Wobrock/django-environ that referenced this issue Sep 5, 2023
The argument is already documented but not implemented yet.
Fixes joke2k#415
David-Wobrock added a commit to David-Wobrock/django-environ that referenced this issue Sep 5, 2023
The argument is already documented but not implemented yet.
Fixes joke2k#415
David-Wobrock added a commit to David-Wobrock/django-environ that referenced this issue Sep 25, 2023
The argument is already documented but not implemented yet.
Fixes joke2k#415
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants