Opened 7 years ago
Closed 4 years ago
#29324 closed Cleanup/optimization (fixed)
Change Settings to raise ImproperlyConfigured on SECRET_KEY; not initialization
Reported by: | Jon Dufresne | Owned by: | Florian Apolloner |
---|---|---|---|
Component: | Core (Other) | Version: | 2.1 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Since ticket #17800, initializing settings without a SECRET_KEY
raises a an ImproperlyConfigured
during settings initialization.
Instead, I think the error should be raised when the setting is accessed as Settings.SECRET_KEY
.
My use case, my project has a number of management commands that run in a non-production, minimally configured environment. These management commands do not require SECRET_KEY
, however, the environment is forced to provide one.
As a workaround this environment has been generating a random secret key each run. If Django were to instead raise the error on SECRET_KEY
access, this workaround would not be necessary.
Change History (17)
comment:1 by , 7 years ago
Has patch: | set |
---|
comment:2 by , 7 years ago
Patch needs improvement: | set |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:5 by , 7 years ago
Resolution: | fixed |
---|---|
Severity: | Normal → Release blocker |
Status: | closed → new |
This causes a regression when using settings.configure()
. UserSettingsHolder
does not handle the missing SECRET_KEY
attribute, and raises an AttributeError
instead of ImproperlyConfigured
.
(Discovered by bukensik in #django)
comment:6 by , 7 years ago
Has patch: | unset |
---|---|
Version: | master → 2.1 |
comment:10 by , 7 years ago
Has patch: | unset |
---|---|
Resolution: | fixed |
Severity: | Release blocker → Normal |
Status: | closed → new |
I reverted the original patch for now as Claude expressed some concerns, "I'm not sure to like the additional test for every setting access, for a corner-case use case. I think we should consider reverting the initial patch instead."
I'll leave the ticket open for Jon to provide an alternative patch or to close the ticket as wontfix.
comment:12 by , 6 years ago
Patch needs improvement: | set |
---|
comment:13 by , 6 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
After researching the code necessary to handle the edge cases, I don't think the complexity is worth it to include in Django. I'll stick with my local project workaround instead.
comment:14 by , 4 years ago
Resolution: | wontfix |
---|---|
Status: | closed → new |
Reopening after recent ML discussion: https://groups.google.com/g/django-developers/c/CIPgeTetYpk
comment:15 by , 4 years ago
Owner: | changed from | to
---|---|
Patch needs improvement: | unset |
Status: | new → assigned |
comment:16 by , 4 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
PR