traceback on api access
hart323 opened this issue · 2 comments
hart323 commented
Validity Version
3.0.3
NetBox Version
4.1.1
Python Version
3.12.3
Steps to Reproduce
Traceback on https://netbox.company.com/api/plugins/validity/test-results/
Traceback
ImproperlyConfigured at /api/plugins/validity/test-results/
Could not resolve URL for hyperlinked relationship using view name "". You may have failed to include the related model in your API, or incorrectly configured the `lookup_field` attribute on this field.
Request Method: GET
Request URL: https://netbox.company.com/api/plugins/validity/test-results/
Django Version: 5.0.9
Exception Type: ImproperlyConfigured
Exception Value:
Could not resolve URL for hyperlinked relationship using view name "". You may have failed to include the related model in your API, or incorrectly configured the `lookup_field` attribute on this field.
Exception Location: /opt/netbox/venv/lib/python3.12/site-packages/rest_framework/relations.py, line 411, in to_representation
Raised during: validity.api.views.ComplianceTestResultViewSet
Python Executable: /opt/netbox/venv/bin/python
Python Version: 3.12.3
Python Path:
['/opt/netbox/netbox/',
'/usr/lib/python312.zip',
'/usr/lib/python3.12',
'/usr/lib/python3.12/lib-dynload',
'/opt/netbox/venv/lib/python3.12/site-packages']
Server time: Thu, 03 Oct 2024 15:39:50 +0300
Environment:
Request Method: GET
Request URL: https://netbox.company.com/api/plugins/validity/test-results/
Django Version: 5.0.9
Python Version: 3.12.3
Installed Applications:
['django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.humanize',
'django.forms',
'corsheaders',
'debug_toolbar',
'django_filters',
'django_htmx',
'django_tables2',
'django_prometheus',
'strawberry_django',
'mptt',
'rest_framework',
'social_django',
'taggit',
'timezone_field',
'core',
'account',
'circuits',
'dcim',
'ipam',
'extras',
'tenancy',
'users',
'utilities',
'virtualization',
'vpn',
'wireless',
'django_rq',
'drf_spectacular',
'drf_spectacular_sidecar',
'django_bootstrap5',
'validity.NetBoxValidityConfig']
Installed Middleware:
['django_prometheus.middleware.PrometheusBeforeMiddleware',
'strawberry_django.middlewares.debug_toolbar.DebugToolbarMiddleware',
'corsheaders.middleware.CorsMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware',
'django_htmx.middleware.HtmxMiddleware',
'netbox.middleware.RemoteUserMiddleware',
'netbox.middleware.CoreMiddleware',
'netbox.middleware.MaintenanceModeMiddleware',
'django_prometheus.middleware.PrometheusAfterMiddleware']
Traceback (most recent call last):
File "/opt/netbox/venv/lib/python3.12/site-packages/rest_framework/reverse.py", line 41, in reverse
url = scheme.reverse(viewname, args, kwargs, request, format, **extra)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/netbox/venv/lib/python3.12/site-packages/rest_framework/versioning.py", line 25, in reverse
return _reverse(viewname, args, kwargs, request, format, **extra)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/netbox/venv/lib/python3.12/site-packages/rest_framework/reverse.py", line 60, in _reverse
url = django_reverse(viewname, args=args, kwargs=kwargs, **extra)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/netbox/venv/lib/python3.12/site-packages/django/urls/base.py", line 88, in reverse
return resolver._reverse_with_prefix(view, prefix, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/netbox/venv/lib/python3.12/site-packages/django/urls/resolvers.py", line 851, in _reverse_with_prefix
raise NoReverseMatch(msg)
^^^^^^^^^^^^^^^^^^^^^^^^^
During handling of the above exception (Reverse for 'vdevice-detail' not found. 'vdevice-detail' is not a valid view function or pattern name.), another exception occurred:
File "/opt/netbox/venv/lib/python3.12/site-packages/rest_framework/relations.py", line 396, in to_representation
url = self.get_url(value, self.view_name, request, format)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/netbox/netbox/netbox/api/serializers/fields.py", line 37, in get_url
return self.reverse(view_name, kwargs=kwargs, request=request, format=format)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/netbox/venv/lib/python3.12/site-packages/rest_framework/reverse.py", line 45, in reverse
url = _reverse(viewname, args, kwargs, request, format, **extra)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/netbox/venv/lib/python3.12/site-packages/rest_framework/reverse.py", line 60, in _reverse
url = django_reverse(viewname, args=args, kwargs=kwargs, **extra)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/netbox/venv/lib/python3.12/site-packages/django/urls/base.py", line 88, in reverse
return resolver._reverse_with_prefix(view, prefix, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/netbox/venv/lib/python3.12/site-packages/django/urls/resolvers.py", line 851, in _reverse_with_prefix
raise NoReverseMatch(msg)
^^^^^^^^^^^^^^^^^^^^^^^^^
During handling of the above exception (Reverse for 'vdevice-detail' not found. 'vdevice-detail' is not a valid view function or pattern name.), another exception occurred:
File "/opt/netbox/venv/lib/python3.12/site-packages/django/core/handlers/exception.py", line 55, in inner
response = get_response(request)
^^^^^^^^^^^^^^^^^^^^^
File "/opt/netbox/venv/lib/python3.12/site-packages/django/core/handlers/base.py", line 197, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/netbox/venv/lib/python3.12/site-packages/django/views/decorators/csrf.py", line 65, in _view_wrapper
return view_func(request, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/netbox/venv/lib/python3.12/site-packages/rest_framework/viewsets.py", line 124, in view
return self.dispatch(request, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/netbox/venv/lib/python3.12/site-packages/rest_framework/views.py", line 509, in dispatch
response = self.handle_exception(exc)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/netbox/venv/lib/python3.12/site-packages/rest_framework/views.py", line 469, in handle_exception
self.raise_uncaught_exception(exc)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/netbox/venv/lib/python3.12/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
raise exc
^^^^^^^^^
File "/opt/netbox/venv/lib/python3.12/site-packages/rest_framework/views.py", line 506, in dispatch
response = handler(request, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/netbox/netbox/netbox/api/viewsets/mixins.py", line 50, in list
return super().list(request, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/netbox/venv/lib/python3.12/site-packages/rest_framework/mixins.py", line 43, in list
return self.get_paginated_response(serializer.data)
^^^^^^^^^^^^^^^
File "/opt/netbox/venv/lib/python3.12/site-packages/rest_framework/serializers.py", line 795, in data
ret = super().data
^^^^^^^^^^^^
File "/opt/netbox/venv/lib/python3.12/site-packages/rest_framework/serializers.py", line 249, in data
self._data = self.to_representation(self.instance)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/netbox/venv/lib/python3.12/site-packages/rest_framework/serializers.py", line 714, in to_representation
self.child.to_representation(item) for item in iterable
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/netbox/venv/lib/python3.12/site-packages/rest_framework/serializers.py", line 538, in to_representation
ret[field.field_name] = field.to_representation(attribute)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/netbox/venv/lib/python3.12/site-packages/rest_framework/serializers.py", line 538, in to_representation
ret[field.field_name] = field.to_representation(attribute)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/netbox/venv/lib/python3.12/site-packages/rest_framework/relations.py", line 411, in to_representation
raise ImproperlyConfigured(msg % self.view_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Exception Type: ImproperlyConfigured at /api/plugins/validity/test-results/
Exception Value: Could not resolve URL for hyperlinked relationship using view name "". You may have failed to include the related model in your API, or incorrectly configured the `lookup_field` attribute on this field.
amyasnikov commented
I guess it's NetBox 4.1.2+, not 4.1.1 as it's stated in the issue header. Please be careful with this info.
Probably definitely broken by netbox-community/netbox#17493
Immediate fix: use NetBox 4.1.1
amyasnikov commented
@hart323 thanks for the issue, fixed