-
Notifications
You must be signed in to change notification settings - Fork 55
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
Bug With PLUGIN_CFG Constant #754
Comments
We would need something from core to do something reasonable about this, yes we could fix this current challenge but I am not sure it is worth it tbh, at some point you will get stack traces, this is a documented requirement, so not sure how much we want to work around it. In core, we could add validation to NautobotAppConfig to say "must provide a config" and check for that first and return a sane message. something like: class AnimalSoundsConfig(NautobotAppConfig):
name = 'nautobot_animal_sounds'
verbose_name = 'Animal Sounds'
config_required = True
config = AnimalSoundsConfig |
Well I feel like this could also be handled with using a get() for each of the settings instead of assuming they're there. I had another pop up from another setting that's not even in the dev environment example:
Each of these would be solved by just using a get(). This would also affect users who are setting up the App and don't have their settings exactly as expected. Just like general exception handling I'd expect a check for the setting existing and not assuming it's there and throwing an Exception or log if missing. |
For the the specific case of |
To recreate you just need a Nautobot App with a Golden Config dependency and not have |
I am not able to re-produce starting the application off using a standard
This may be similar to what we have to do in pylint (which I know you got bit on today :) ) in that we have to start the app in order to access any values. |
It could be that it was happening during the unit testing phase and activated due to the import of a model from Golden Config. |
Environment
Expected Behavior
Add Golden Config App as dependency to another App would not require plugin configuration for Golden Config App in nautobot_config.py
Observed Behavior
Addition of Golden Config App as dependency but not adding
nautobot_golden_config
to PLUGINS_CONFIG in nautobot_config.py causes a KeyError to be thrown:Traceback (most recent call last):
File "/usr/local/bin/nautobot-server", line 8, in
sys.exit(main())
^^^^^^
File "/usr/local/lib/python3.11/site-packages/nautobot/core/cli/init.py", line 54, in main
run_app(
File "/usr/local/lib/python3.11/site-packages/nautobot/core/runner/runner.py", line 297, in run_app
management.execute_from_command_line([runner_name, command] + command_args)
File "/usr/local/lib/python3.11/site-packages/django/core/management/init.py", line 419, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python3.11/site-packages/django/core/management/init.py", line 395, in execute
django.setup()
File "/usr/local/lib/python3.11/site-packages/django/init.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/usr/local/lib/python3.11/site-packages/django/apps/registry.py", line 122, in populate
app_config.ready()
File "/usr/local/lib/python3.11/site-packages/nautobot/extras/plugins/init.py", line 144, in ready
jobs = import_object(f"{self.module}.{self.jobs}")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/nautobot/extras/plugins/utils.py", line 46, in import_object
spec.loader.exec_module(module)
File "", line 940, in exec_module
File "", line 241, in _call_with_frames_removed
File "/source/nautobot_fallout/jobs.py", line 10, in
from nautobot_golden_config.models import GoldenConfig
File "/usr/local/lib/python3.11/site-packages/nautobot_golden_config/models.py", line 20, in
from nautobot_golden_config.utilities.constant import ENABLE_SOTAGG, PLUGIN_CFG
File "/usr/local/lib/python3.11/site-packages/nautobot_golden_config/utilities/constant.py", line 5, in
PLUGIN_CFG = settings.PLUGINS_CONFIG["nautobot_golden_config"]
~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
KeyError: 'nautobot_golden_config'
Steps to Reproduce
nautobot_golden_config
to PLUGINS_CONFIG section of nautobot_config.pyThe text was updated successfully, but these errors were encountered: