Add extra feedback on Secret Key to small exception #8359

Closed
opened 2025-12-29 20:35:47 +01:00 by adam · 1 comment
Owner

Originally created by @caskings on GitHub (Jul 25, 2023).

NetBox version

v3.5.6

Feature type

Change to existing functionality

Proposed functionality

When upgrading to 3.5 and above from an earlier release if the secret key is to small, the error tells you how to generate a new key but not where to put it.

netbox/netbox/settings.py (line 75)

f"SECRET_KEY must be at least 50 characters in length. To generate a suitable key, run the following command:\n"
f" python {BASE_DIR}/generate_secret_key.py"

I would suggest adding extra details in pointing to the config file etc.

f"SECRET_KEY must be at least 50 characters in length. To generate a suitable key, run the following command:\n"
f" python {BASE_DIR}/generate_secret_key.py\n"
f"Use the output to update the [SECRET_KEY] section of the configuration file {BASE_DIR}/netbox/configuration.py\n"
f"https://demo.netbox.dev/static/docs/configuration/required-parameters/#secret_key"

Happy to submit a pull request if this is accepted.

Use case

This change would help users during the upgrade process by pointing them to the exact thing they need to fix to continue the upgrade process.

Database changes

No response

External dependencies

No response

Originally created by @caskings on GitHub (Jul 25, 2023). ### NetBox version v3.5.6 ### Feature type Change to existing functionality ### Proposed functionality When upgrading to 3.5 and above from an earlier release if the secret key is to small, the error tells you how to generate a new key but not where to put it. netbox/netbox/settings.py (line 75) f"SECRET_KEY must be at least 50 characters in length. To generate a suitable key, run the following command:\n" f" python {BASE_DIR}/generate_secret_key.py" I would suggest adding extra details in pointing to the config file etc. f"SECRET_KEY must be at least 50 characters in length. To generate a suitable key, run the following command:\n" f" python {BASE_DIR}/generate_secret_key.py\n" f"Use the output to update the [SECRET_KEY] section of the configuration file {BASE_DIR}/netbox/configuration.py\n" f"https://demo.netbox.dev/static/docs/configuration/required-parameters/#secret_key" Happy to submit a pull request if this is accepted. ### Use case This change would help users during the upgrade process by pointing them to the exact thing they need to fix to continue the upgrade process. ### Database changes _No response_ ### External dependencies _No response_
adam added the type: feature label 2025-12-29 20:35:47 +01:00
adam closed this issue 2025-12-29 20:35:47 +01:00
Author
Owner

@jeremystretch commented on GitHub (Oct 13, 2023):

the error tells you how to generate a new key but not where to put it.

I'm afraid the definition of the secret key, as with other configuration parameters, is highly dependent on the manner in which NetBox was installed (e.g. as a container vs. containerless). Instructing a specific course of action for the administrator would in some cases likely do more harm than good. And IMO it's very reasonable to expect the administrator to know where this change should be applied anyway.

@jeremystretch commented on GitHub (Oct 13, 2023): > the error tells you how to generate a new key but not where to put it. I'm afraid the definition of the secret key, as with other configuration parameters, is highly dependent on the manner in which NetBox was installed (e.g. as a container vs. containerless). Instructing a specific course of action for the administrator would in some cases likely do more harm than good. And IMO it's very reasonable to expect the administrator to know where this change should be applied anyway.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#8359