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

Incorrect/misleading error message when there is a logic that has an error in PLUGINS_CONFIG > nautobot_ssot #5677

Open
nathanielfernandez opened this issue May 7, 2024 · 1 comment
Labels
question Further information is requested type: bug Something isn't working as expected

Comments

@nathanielfernandez
Copy link

nathanielfernandez commented May 7, 2024

Environment

  • Nautobot version (Docker tag too if applicable): 2.1.5, VM install (non-docker)
  • Python version: 3.10.12
  • Database platform, version: psql (PostgreSQL) 16.2 (Ubuntu 16.2-1.pgdg22.04+1)
  • Middleware(s): Nautobot is running on Ubuntu 22.04.3 LTS

Steps to Reproduce

  1. Open nautobot_config.py and go to PLUGINS_CONFIG > nautobot_ssot dictionary.
  2. In our case, we are using the infoblox ssot plugin. Try to insert a key-value pair that has an incorrect logic, like applying .split() to a list. Then save the file.

"infoblox_import_subnets": [x for x in ["10.0.0.0/8","172.16.0.0/12","192.168.0.0/16"].split(",") if x]

Note: Tried this one in python (cli). The above should give an AttributeError because a list does not have .split() attribute.

  1. When you run nautobot-server post_upgrade, you'll get an error message about SECRET_KEY being empty, even though it has a value in nautobot_config.py.
nautobot@lab:~$ nautobot-server post_upgrade
Traceback (most recent call last):
  File "/opt/nautobot/bin/nautobot-server", line 8, in <module>
    sys.exit(main())
  File "/opt/nautobot/lib/python3.10/site-packages/nautobot/core/cli/__init__.py", line 52, in main
    run_app(
  File "/opt/nautobot/lib/python3.10/site-packages/nautobot/core/runner/runner.py", line 297, in run_app
    management.execute_from_command_line([runner_name, command, *command_args])
  File "/opt/nautobot/lib/python3.10/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
    utility.execute()
  File "/opt/nautobot/lib/python3.10/site-packages/django/core/management/__init__.py", line 395, in execute
    django.setup()
  File "/opt/nautobot/lib/python3.10/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/opt/nautobot/lib/python3.10/site-packages/django/apps/registry.py", line 122, in populate
    app_config.ready()
  File "/opt/nautobot/lib/python3.10/site-packages/nautobot/core/apps/__init__.py", line 846, in ready
    super().ready()
  File "/opt/nautobot/lib/python3.10/site-packages/nautobot/core/apps/__init__.py", line 68, in ready
    registry["new_ui_ready_routes"].update(get_all_new_ui_ready_routes())
  File "/opt/nautobot/lib/python3.10/site-packages/nautobot/core/utils/navigation.py", line 47, in get_all_new_ui_ready_routes
    url_patterns = resolver.url_patterns
  File "/opt/nautobot/lib/python3.10/site-packages/django/utils/functional.py", line 48, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/opt/nautobot/lib/python3.10/site-packages/django/urls/resolvers.py", line 602, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/opt/nautobot/lib/python3.10/site-packages/django/utils/functional.py", line 48, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/opt/nautobot/lib/python3.10/site-packages/django/urls/resolvers.py", line 595, in urlconf_module
    return import_module(self.urlconf_name)
  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/opt/nautobot/lib/python3.10/site-packages/nautobot/core/urls.py", line 7, in <module>
    from nautobot.core.views import (
  File "/opt/nautobot/lib/python3.10/site-packages/nautobot/core/views/__init__.py", line 11, in <module>
    from django.contrib.auth.mixins import AccessMixin, LoginRequiredMixin
  File "/opt/nautobot/lib/python3.10/site-packages/django/contrib/auth/mixins.py", line 5, in <module>
    from django.contrib.auth.views import redirect_to_login
  File "/opt/nautobot/lib/python3.10/site-packages/django/contrib/auth/views.py", line 10, in <module>
    from django.contrib.auth.forms import (
  File "/opt/nautobot/lib/python3.10/site-packages/django/contrib/auth/forms.py", line 11, in <module>
    from django.contrib.auth.tokens import default_token_generator
  File "/opt/nautobot/lib/python3.10/site-packages/django/contrib/auth/tokens.py", line 117, in <module>
    default_token_generator = PasswordResetTokenGenerator()
  File "/opt/nautobot/lib/python3.10/site-packages/django/contrib/auth/tokens.py", line 18, in __init__
    self.secret = self.secret or settings.SECRET_KEY
  File "/opt/nautobot/lib/python3.10/site-packages/django/conf/__init__.py", line 90, in __getattr__
    raise ImproperlyConfigured("The SECRET_KEY setting must not be empty.")
django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty.

Expected Behavior

We were expecting to see the AttributeError instead of the SECRET_KEY being empty.

Observed Behavior

We saw the incorrect error message above. This could be a potential red herring to other engineers too.

@nathanielfernandez nathanielfernandez added triage This issue is new and has not been reviewed. type: bug Something isn't working as expected labels May 7, 2024
@lampwins
Copy link
Member

@nathanielfernandez could you try this on the latest release of 2.2? We changed some of the startup logic and are curious is that has any effect.

@glennmatthews glennmatthews added question Further information is requested and removed triage This issue is new and has not been reviewed. labels May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested type: bug Something isn't working as expected
Projects
None yet
Development

No branches or pull requests

3 participants