Problem importing 'IsAuthenticatedOrLoginNotRequired' after upgrading to 2.10.1 #4367

Closed
opened 2025-12-29 18:35:17 +01:00 by adam · 2 comments
Owner

Originally created by @tim427 on GitHub (Dec 16, 2020).

Environment

  • Python version: 3.8.3
  • NetBox version: 2.10.1

Steps to Reproduce

systemctl stop netbox.service netbox-rq.service nginx.service
cd /opt/netbox
git checkout master
git pull origin master
git status
./upgrade.sh
systemctl start netbox.service netbox-rq.service nginx.service

Expected Behavior

Migrations/upgrade to be successful.

Observed Behavior

<class 'ImportError'>

cannot import name 'IsAuthenticatedOrLoginNotRequired' from 'utilities.api' (/opt/netbox/netbox/utilities/api.py)
Full Traceback:
(venv) [root@admin01 netbox]# python3 netbox/manage.py migrate
Traceback (most recent call last):
  File "netbox/manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/opt/netbox/venv/lib64/python3.8/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "/opt/netbox/venv/lib64/python3.8/site-packages/django/core/management/__init__.py", line 395, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/opt/netbox/venv/lib64/python3.8/site-packages/django/core/management/base.py", line 330, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/opt/netbox/venv/lib64/python3.8/site-packages/django/core/management/base.py", line 371, in execute
    output = self.handle(*args, **options)
  File "/opt/netbox/venv/lib64/python3.8/site-packages/django/core/management/base.py", line 85, in wrapped
    res = handle_func(*args, **kwargs)
  File "/opt/netbox/venv/lib64/python3.8/site-packages/django/core/management/commands/migrate.py", line 75, in handle
    self.check(databases=[database])
  File "/opt/netbox/venv/lib64/python3.8/site-packages/django/core/management/base.py", line 392, in check
    all_issues = checks.run_checks(
  File "/opt/netbox/venv/lib64/python3.8/site-packages/django/core/checks/registry.py", line 70, in run_checks
    new_errors = check(app_configs=app_configs, databases=databases)
  File "/opt/netbox/venv/lib64/python3.8/site-packages/django/core/checks/urls.py", line 13, in check_url_config
    return check_resolver(resolver)
  File "/opt/netbox/venv/lib64/python3.8/site-packages/django/core/checks/urls.py", line 23, in check_resolver
    return check_method()
  File "/opt/netbox/venv/lib64/python3.8/site-packages/django/urls/resolvers.py", line 408, in check
    for pattern in self.url_patterns:
  File "/opt/netbox/venv/lib64/python3.8/site-packages/django/utils/functional.py", line 48, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/opt/netbox/venv/lib64/python3.8/site-packages/django/urls/resolvers.py", line 589, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/opt/netbox/venv/lib64/python3.8/site-packages/django/utils/functional.py", line 48, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/opt/netbox/venv/lib64/python3.8/site-packages/django/urls/resolvers.py", line 582, in urlconf_module
    return import_module(self.urlconf_name)
  File "/usr/lib64/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/opt/netbox/netbox/netbox/urls.py", line 8, in <module>
    from extras.plugins.urls import plugin_admin_patterns, plugin_patterns, plugin_api_patterns
  File "/opt/netbox/netbox/extras/plugins/urls.py", line 35, in <module>
    urlpatterns = import_object(f"{plugin_path}.api.urls.urlpatterns")
  File "/opt/netbox/netbox/extras/plugins/utils.py", line 31, in import_object
    spec.loader.exec_module(module)
  File "/opt/netbox/venv/lib64/python3.8/site-packages/netbox_topology_views/api/urls.py", line 3, in <module>
    from .views import PreSelectDeviceRolesViewSet, SearchViewSet, SaveCoordsViewSet, PreSelectTagsViewSet
  File "/opt/netbox/venv/lib64/python3.8/site-packages/netbox_topology_views/api/views.py", line 9, in <module>
    from utilities.api import IsAuthenticatedOrLoginNotRequired
ImportError: cannot import name 'IsAuthenticatedOrLoginNotRequired' from 'utilities.api' (/opt/netbox/netbox/utilities/api.py)
Originally created by @tim427 on GitHub (Dec 16, 2020). <!-- NOTE: IF YOUR ISSUE DOES NOT FOLLOW THIS TEMPLATE, IT WILL BE CLOSED. This form is only for reporting reproducible bugs. If you need assistance with NetBox installation, or if you have a general question, please start a discussion instead: https://github.com/netbox-community/netbox/discussions Please describe the environment in which you are running NetBox. Be sure that you are running an unmodified instance of the latest stable release before submitting a bug report, and that any plugins have been disabled. --> ### Environment * Python version: 3.8.3 * NetBox version: 2.10.1 <!-- Describe in detail the exact steps that someone else can take to reproduce this bug using the current stable release of NetBox. Begin with the creation of any necessary database objects and call out every operation being performed explicitly. If reporting a bug in the REST API, be sure to reconstruct the raw HTTP request(s) being made: Don't rely on a client library such as pynetbox. --> ### Steps to Reproduce ``` systemctl stop netbox.service netbox-rq.service nginx.service cd /opt/netbox git checkout master git pull origin master git status ./upgrade.sh systemctl start netbox.service netbox-rq.service nginx.service ``` <!-- What did you expect to happen? --> ### Expected Behavior Migrations/upgrade to be successful. <!-- What happened instead? --> ### Observed Behavior ``` <class 'ImportError'> cannot import name 'IsAuthenticatedOrLoginNotRequired' from 'utilities.api' (/opt/netbox/netbox/utilities/api.py) ``` <details> <summary>Full Traceback:</summary> ``` (venv) [root@admin01 netbox]# python3 netbox/manage.py migrate Traceback (most recent call last): File "netbox/manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "/opt/netbox/venv/lib64/python3.8/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line utility.execute() File "/opt/netbox/venv/lib64/python3.8/site-packages/django/core/management/__init__.py", line 395, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/opt/netbox/venv/lib64/python3.8/site-packages/django/core/management/base.py", line 330, in run_from_argv self.execute(*args, **cmd_options) File "/opt/netbox/venv/lib64/python3.8/site-packages/django/core/management/base.py", line 371, in execute output = self.handle(*args, **options) File "/opt/netbox/venv/lib64/python3.8/site-packages/django/core/management/base.py", line 85, in wrapped res = handle_func(*args, **kwargs) File "/opt/netbox/venv/lib64/python3.8/site-packages/django/core/management/commands/migrate.py", line 75, in handle self.check(databases=[database]) File "/opt/netbox/venv/lib64/python3.8/site-packages/django/core/management/base.py", line 392, in check all_issues = checks.run_checks( File "/opt/netbox/venv/lib64/python3.8/site-packages/django/core/checks/registry.py", line 70, in run_checks new_errors = check(app_configs=app_configs, databases=databases) File "/opt/netbox/venv/lib64/python3.8/site-packages/django/core/checks/urls.py", line 13, in check_url_config return check_resolver(resolver) File "/opt/netbox/venv/lib64/python3.8/site-packages/django/core/checks/urls.py", line 23, in check_resolver return check_method() File "/opt/netbox/venv/lib64/python3.8/site-packages/django/urls/resolvers.py", line 408, in check for pattern in self.url_patterns: File "/opt/netbox/venv/lib64/python3.8/site-packages/django/utils/functional.py", line 48, in __get__ res = instance.__dict__[self.name] = self.func(instance) File "/opt/netbox/venv/lib64/python3.8/site-packages/django/urls/resolvers.py", line 589, in url_patterns patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module) File "/opt/netbox/venv/lib64/python3.8/site-packages/django/utils/functional.py", line 48, in __get__ res = instance.__dict__[self.name] = self.func(instance) File "/opt/netbox/venv/lib64/python3.8/site-packages/django/urls/resolvers.py", line 582, in urlconf_module return import_module(self.urlconf_name) File "/usr/lib64/python3.8/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1014, in _gcd_import File "<frozen importlib._bootstrap>", line 991, in _find_and_load File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 671, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 783, in exec_module File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "/opt/netbox/netbox/netbox/urls.py", line 8, in <module> from extras.plugins.urls import plugin_admin_patterns, plugin_patterns, plugin_api_patterns File "/opt/netbox/netbox/extras/plugins/urls.py", line 35, in <module> urlpatterns = import_object(f"{plugin_path}.api.urls.urlpatterns") File "/opt/netbox/netbox/extras/plugins/utils.py", line 31, in import_object spec.loader.exec_module(module) File "/opt/netbox/venv/lib64/python3.8/site-packages/netbox_topology_views/api/urls.py", line 3, in <module> from .views import PreSelectDeviceRolesViewSet, SearchViewSet, SaveCoordsViewSet, PreSelectTagsViewSet File "/opt/netbox/venv/lib64/python3.8/site-packages/netbox_topology_views/api/views.py", line 9, in <module> from utilities.api import IsAuthenticatedOrLoginNotRequired ImportError: cannot import name 'IsAuthenticatedOrLoginNotRequired' from 'utilities.api' (/opt/netbox/netbox/utilities/api.py) ``` </details>
adam closed this issue 2025-12-29 18:35:17 +01:00
Author
Owner

@rodvand commented on GitHub (Dec 16, 2020):

I believe this is related to the netbox_topology_views plugin. Disable this and the upgrade should work fine. You should create an issue with the plugin to have them update it for 2.10.

Edit: I see it's already an issue for it: https://github.com/mattieserver/netbox-topology-views/issues/48

@rodvand commented on GitHub (Dec 16, 2020): I believe this is related to the netbox_topology_views plugin. Disable this and the upgrade should work fine. You should create an issue with the plugin to have them update it for 2.10. Edit: I see it's already an issue for it: https://github.com/mattieserver/netbox-topology-views/issues/48
Author
Owner

@tim427 commented on GitHub (Dec 16, 2020):

@rodvand You are absolutely right! How could I've missed that.

Grabbing another coffee!

@tim427 commented on GitHub (Dec 16, 2020): @rodvand You are absolutely right! How could I've missed that. _Grabbing another coffee!_
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#4367