cookiecutter / cookiecutter-django

Cookiecutter Django is a framework for jumpstarting production-ready Django projects quickly.
https://cookiecutter-django.readthedocs.io
BSD 3-Clause "New" or "Revised" License
12.1k stars 2.89k forks source link

Some SECRET_KEY default values cause recursion error in environ.py #454

Closed chromakey closed 6 years ago

chromakey commented 8 years ago

This SECRET_KEY declaration causes a maximum recursion depth exceeded error. (Note: I never used this secret key value anywhere since I was just starting the project)

SECRET_KEY = env("DJANGO_SECRET_KEY", default='$%ify^q7jg*o7(5me*g%+ae-7_1iy)gey*#eo%3c##-=1d=6mb')

Results in:

...snip...
  File "/Users/chromakey/.virtualenvs/xxxx/lib/python3.4/site-packages/environ/environ.py", line 260, in get_value
    value = self.get_value(value, cast=cast, default=default)
  File "/Users/chromakey/.virtualenvs/xxxx/lib/python3.4/site-packages/environ/environ.py", line 260, in get_value
    value = self.get_value(value, cast=cast, default=default)
  File "/Users/chromakey/.virtualenvs/xxxx/lib/python3.4/site-packages/environ/environ.py", line 249, in get_value
    value = os.environ[var]
  File "/Users/chromakey/.virtualenvs/xxxx/bin/../lib/python3.4/os.py", line 630, in __getitem__
    value = self._data[self.encodekey(key)]
RuntimeError: maximum recursion depth exceeded

This however, causes no error:

SECRET_KEY = env("DJANGO_SECRET_KEY", default='12345')

I am using the 1.8.7 release since I'll need LTS. I'm not blocked since I can just change the secret key value, but thought I'd let you know. Thanks for all of your hard work!

chromakey commented 8 years ago

It looks like it's the fact that it starts with $ is what's breaking it.

pydanny commented 8 years ago

Shouldn't this be filed under django-environ?

chromakey commented 8 years ago

I reckon you're right. I'll post it there.

jayfk commented 7 years ago

Seems like this is still an issue: https://travis-ci.org/pydanny/cookiecutter-django/jobs/216695020

jayfk commented 7 years ago

And here https://travis-ci.org/pydanny/cookiecutter-django/jobs/207931982 and here https://travis-ci.org/pydanny/cookiecutter-django/jobs/206205275.

Here is the bug @chromakey opened: https://travis-ci.org/pydanny/cookiecutter-django/jobs/206205275

Should we look for a library that isn't limited in such a way that it doesn't support environment variables with a $ sign? This isn't such a big problem with a secret key we set on our own, but what about credentials from a 3rd party we can't change?

browniebroke commented 6 years ago

For reference, here is the bug in django-environ: https://github.com/joke2k/django-environ/issues/60