swagger-ui to get "Failed to load API definition" #8016

Closed
opened 2025-12-29 20:31:10 +01:00 by adam · 4 comments
Owner

Originally created by @xth0331 on GitHub (May 8, 2023).

NetBox version

v3.5.1

Python version

3.8

Steps to Reproduce

After upgrading to 3.5.1, accessing the REST API documentation (http://netbox/api/schema/swagger-ui/) will prompt "Failed to load API definition.", and the prompt below shows response status is 500 /api/schema/

Expected Behavior

Access to swagger-ui

Observed Behavior

  1. The log shows as follows:
2023-05-08 15:09:42,910 django.request ERROR: Internal Server Error: /api/schema/
Traceback (most recent call last):
  File "/opt/netbox-3.5.1/venv/lib64/python3.8/site-packages/django/core/handlers/exception.py", line 56, in inner
    response = get_response(request)
  File "/opt/netbox-3.5.1/venv/lib64/python3.8/site-packages/django/core/handlers/base.py", line 197, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/opt/netbox-3.5.1/venv/lib64/python3.8/site-packages/django/views/decorators/csrf.py", line 55, in wrapped_view
    return view_func(*args, **kwargs)
  File "/opt/netbox-3.5.1/venv/lib64/python3.8/site-packages/django/views/generic/base.py", line 103, in view
    return self.dispatch(request, *args, **kwargs)
  File "/opt/netbox-3.5.1/venv/lib64/python3.8/site-packages/rest_framework/views.py", line 509, in dispatch
    response = self.handle_exception(exc)
  File "/opt/netbox-3.5.1/venv/lib64/python3.8/site-packages/rest_framework/views.py", line 469, in handle_exception
    self.raise_uncaught_exception(exc)
  File "/opt/netbox-3.5.1/venv/lib64/python3.8/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
    raise exc
  File "/opt/netbox-3.5.1/venv/lib64/python3.8/site-packages/rest_framework/views.py", line 506, in dispatch
    response = handler(request, *args, **kwargs)
  File "/opt/netbox-3.5.1/venv/lib64/python3.8/site-packages/drf_spectacular/views.py", line 83, in get
    return self._get_schema_response(request)
  File "/opt/netbox-3.5.1/venv/lib64/python3.8/site-packages/drf_spectacular/views.py", line 91, in _get_schema_response
    data=generator.get_schema(request=request, public=self.serve_public),
  File "/opt/netbox-3.5.1/venv/lib64/python3.8/site-packages/drf_spectacular/generators.py", line 268, in get_schema
    paths=self.parse(request, public),
  File "/opt/netbox-3.5.1/venv/lib64/python3.8/site-packages/drf_spectacular/generators.py", line 239, in parse
    operation = view.schema.get_operation(
  File "/opt/netbox-3.5.1/venv/lib64/python3.8/site-packages/drf_spectacular/openapi.py", line 83, in get_operation
    request_body = self._get_request_body()
  File "/opt/netbox/netbox/core/api/schema.py", line 191, in _get_request_body
    return super()._get_request_body(direction)
  File "/opt/netbox-3.5.1/venv/lib64/python3.8/site-packages/drf_spectacular/openapi.py", line 1247, in _get_request_body
    request_serializer = self.get_request_serializer()
  File "/opt/netbox/netbox/core/api/schema.py", line 103, in get_request_serializer
    writable_class = self.get_writable_class(serializer)
  File "/opt/netbox/netbox/core/api/schema.py", line 146, in get_writable_class
    for child_name, child in fields.items():
AttributeError: 'cached_property' object has no attribute 'items'

  1. systemctl status netbox :
May 08 15:09:36 netbox gunicorn[58866]: /opt/netbox/netbox/ipam/filtersets.py: Warning [VLANViewSet > VLANFilterSet]: Unable to guess choice types from values, filter method's type hint or find "available_on_device" in model. Defaulting to string.
May 08 15:09:36 netbox gunicorn[58866]: /opt/netbox/netbox/ipam/filtersets.py: Warning [VLANViewSet > VLANFilterSet]: Unable to guess choice types from values, filter method's type hint or find "available_on_virtualmachine" in model. Defaulting to string.
May 08 15:09:41 netbox gunicorn[58866]: /opt/netbox/netbox/ipam/filtersets.py: Warning [FHRPGroupViewSet > FHRPGroupFilterSet]: Unable to guess choice types from values, filter method's type hint or find "related_ip" in model. Defaulting to string.
May 08 15:09:41 netbox gunicorn[58866]: /opt/netbox/netbox/ipam/filtersets.py: Warning [IPAddressViewSet > IPAddressFilterSet]: Unable to guess choice types from values, filter method's type hint or find "present_in_vrf_id" in model. Defaulting to string.
May 08 15:09:41 netbox gunicorn[58866]: /opt/netbox/netbox/ipam/filtersets.py: Warning [IPAddressViewSet > IPAddressFilterSet]: Unable to guess choice types from values, filter method's type hint or find "present_in_vrf" in model. Defaulting to string.
May 08 15:09:42 netbox gunicorn[58866]: /opt/netbox/netbox/ipam/filtersets.py: Warning [PrefixViewSet > PrefixFilterSet]: Unable to guess choice types from values, filter method's type hint or find "present_in_vrf_id" in model. Defaulting to string.
May 08 15:09:42 netbox gunicorn[58866]: /opt/netbox/netbox/ipam/filtersets.py: Warning [PrefixViewSet > PrefixFilterSet]: Unable to guess choice types from values, filter method's type hint or find "present_in_vrf" in model. Defaulting to string.
May 08 15:09:42 netbox gunicorn[58866]: /opt/netbox/netbox/ipam/filtersets.py: Warning [ServiceViewSet > ServiceFilterSet]: model field "IPAddressField" has no mapping in ModelSerializer. It may be a deprecated field. Defaulting to "string"
May 08 15:09:42 netbox gunicorn[58866]: /opt/netbox/netbox/ipam/filtersets.py: Warning [VLANViewSet > VLANFilterSet]: Unable to guess choice types from values, filter method's type hint or find "available_on_device" in model. Defaulting to string.
May 08 15:09:42 netbox gunicorn[58866]: /opt/netbox/netbox/ipam/filtersets.py: Warning [VLANViewSet > VLANFilterSet]: Unable to guess choice types from values, filter method's type hint or find "available_on_virtualmachine" in model. Defaulting to string.

Originally created by @xth0331 on GitHub (May 8, 2023). ### NetBox version v3.5.1 ### Python version 3.8 ### Steps to Reproduce After upgrading to 3.5.1, accessing the REST API documentation (http://netbox/api/schema/swagger-ui/) will prompt "Failed to load API definition.", and the prompt below shows response status is 500 /api/schema/ ### Expected Behavior Access to swagger-ui ### Observed Behavior 1. The log shows as follows: ``` 2023-05-08 15:09:42,910 django.request ERROR: Internal Server Error: /api/schema/ Traceback (most recent call last): File "/opt/netbox-3.5.1/venv/lib64/python3.8/site-packages/django/core/handlers/exception.py", line 56, in inner response = get_response(request) File "/opt/netbox-3.5.1/venv/lib64/python3.8/site-packages/django/core/handlers/base.py", line 197, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/opt/netbox-3.5.1/venv/lib64/python3.8/site-packages/django/views/decorators/csrf.py", line 55, in wrapped_view return view_func(*args, **kwargs) File "/opt/netbox-3.5.1/venv/lib64/python3.8/site-packages/django/views/generic/base.py", line 103, in view return self.dispatch(request, *args, **kwargs) File "/opt/netbox-3.5.1/venv/lib64/python3.8/site-packages/rest_framework/views.py", line 509, in dispatch response = self.handle_exception(exc) File "/opt/netbox-3.5.1/venv/lib64/python3.8/site-packages/rest_framework/views.py", line 469, in handle_exception self.raise_uncaught_exception(exc) File "/opt/netbox-3.5.1/venv/lib64/python3.8/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception raise exc File "/opt/netbox-3.5.1/venv/lib64/python3.8/site-packages/rest_framework/views.py", line 506, in dispatch response = handler(request, *args, **kwargs) File "/opt/netbox-3.5.1/venv/lib64/python3.8/site-packages/drf_spectacular/views.py", line 83, in get return self._get_schema_response(request) File "/opt/netbox-3.5.1/venv/lib64/python3.8/site-packages/drf_spectacular/views.py", line 91, in _get_schema_response data=generator.get_schema(request=request, public=self.serve_public), File "/opt/netbox-3.5.1/venv/lib64/python3.8/site-packages/drf_spectacular/generators.py", line 268, in get_schema paths=self.parse(request, public), File "/opt/netbox-3.5.1/venv/lib64/python3.8/site-packages/drf_spectacular/generators.py", line 239, in parse operation = view.schema.get_operation( File "/opt/netbox-3.5.1/venv/lib64/python3.8/site-packages/drf_spectacular/openapi.py", line 83, in get_operation request_body = self._get_request_body() File "/opt/netbox/netbox/core/api/schema.py", line 191, in _get_request_body return super()._get_request_body(direction) File "/opt/netbox-3.5.1/venv/lib64/python3.8/site-packages/drf_spectacular/openapi.py", line 1247, in _get_request_body request_serializer = self.get_request_serializer() File "/opt/netbox/netbox/core/api/schema.py", line 103, in get_request_serializer writable_class = self.get_writable_class(serializer) File "/opt/netbox/netbox/core/api/schema.py", line 146, in get_writable_class for child_name, child in fields.items(): AttributeError: 'cached_property' object has no attribute 'items' ``` 2. systemctl status netbox : ``` May 08 15:09:36 netbox gunicorn[58866]: /opt/netbox/netbox/ipam/filtersets.py: Warning [VLANViewSet > VLANFilterSet]: Unable to guess choice types from values, filter method's type hint or find "available_on_device" in model. Defaulting to string. May 08 15:09:36 netbox gunicorn[58866]: /opt/netbox/netbox/ipam/filtersets.py: Warning [VLANViewSet > VLANFilterSet]: Unable to guess choice types from values, filter method's type hint or find "available_on_virtualmachine" in model. Defaulting to string. May 08 15:09:41 netbox gunicorn[58866]: /opt/netbox/netbox/ipam/filtersets.py: Warning [FHRPGroupViewSet > FHRPGroupFilterSet]: Unable to guess choice types from values, filter method's type hint or find "related_ip" in model. Defaulting to string. May 08 15:09:41 netbox gunicorn[58866]: /opt/netbox/netbox/ipam/filtersets.py: Warning [IPAddressViewSet > IPAddressFilterSet]: Unable to guess choice types from values, filter method's type hint or find "present_in_vrf_id" in model. Defaulting to string. May 08 15:09:41 netbox gunicorn[58866]: /opt/netbox/netbox/ipam/filtersets.py: Warning [IPAddressViewSet > IPAddressFilterSet]: Unable to guess choice types from values, filter method's type hint or find "present_in_vrf" in model. Defaulting to string. May 08 15:09:42 netbox gunicorn[58866]: /opt/netbox/netbox/ipam/filtersets.py: Warning [PrefixViewSet > PrefixFilterSet]: Unable to guess choice types from values, filter method's type hint or find "present_in_vrf_id" in model. Defaulting to string. May 08 15:09:42 netbox gunicorn[58866]: /opt/netbox/netbox/ipam/filtersets.py: Warning [PrefixViewSet > PrefixFilterSet]: Unable to guess choice types from values, filter method's type hint or find "present_in_vrf" in model. Defaulting to string. May 08 15:09:42 netbox gunicorn[58866]: /opt/netbox/netbox/ipam/filtersets.py: Warning [ServiceViewSet > ServiceFilterSet]: model field "IPAddressField" has no mapping in ModelSerializer. It may be a deprecated field. Defaulting to "string" May 08 15:09:42 netbox gunicorn[58866]: /opt/netbox/netbox/ipam/filtersets.py: Warning [VLANViewSet > VLANFilterSet]: Unable to guess choice types from values, filter method's type hint or find "available_on_device" in model. Defaulting to string. May 08 15:09:42 netbox gunicorn[58866]: /opt/netbox/netbox/ipam/filtersets.py: Warning [VLANViewSet > VLANFilterSet]: Unable to guess choice types from values, filter method's type hint or find "available_on_virtualmachine" in model. Defaulting to string. ```
adam added the type: bug label 2025-12-29 20:31:10 +01:00
adam closed this issue 2025-12-29 20:31:11 +01:00
Author
Owner

@abhi1693 commented on GitHub (May 8, 2023):

Do you have any plugins installed?

@abhi1693 commented on GitHub (May 8, 2023): Do you have any plugins installed?
Author
Owner

@xth0331 commented on GitHub (May 8, 2023):

Plugins:

  • netbox_topology_views
  • netbox_napalm_plugin
  • netbox_topology_views
@xth0331 commented on GitHub (May 8, 2023): Plugins: - netbox_topology_views - netbox_napalm_plugin - netbox_topology_views
Author
Owner

@abhi1693 commented on GitHub (May 8, 2023):

I'd suggest that you disable the plugins and retry the endpoint. If it comes up, then one of the plugins was likely the issue. You should then enable each plugin one by one to see which ones causes the issue and raise the bug report with the respected plugin.

If the issue still persists, we will need more information to reproduce this on a clean installation of NetBox as I'm not facing this issue.

@abhi1693 commented on GitHub (May 8, 2023): I'd suggest that you disable the plugins and retry the endpoint. If it comes up, then one of the plugins was likely the issue. You should then enable each plugin one by one to see which ones causes the issue and raise the bug report with the respected plugin. If the issue still persists, we will need more information to reproduce this on a clean installation of NetBox as I'm not facing this issue.
Author
Owner

@xth0331 commented on GitHub (May 8, 2023):

Thanks, you are right, after I disabled plugin netbox_topology_views, everything worked fine.

@xth0331 commented on GitHub (May 8, 2023): Thanks, you are right, after I disabled plugin `netbox_topology_views`, everything worked fine.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#8016