Skip to content

Cable Trace of incomplete paths leads to an error 500 #7294

@saschaludwig

Description

@saschaludwig

NetBox version

v3.0.2

Python version

3.9

Steps to Reproduce

  1. Create a device template with 1 rear port (12 slots) and 12 linked front ports

  2. Create two devices with the previously created device template

  3. Add a cable between the two rear ports of those devices

  4. click on "Cable Trace"
    -> first error

  5. Add another cable from one of the front ports to an existing interface

  6. click on "Cable Trace" in the device
    -> second error

Expected Behavior

Show Cable Trace of the known parts of the trace, regardless of incomplete paths

Observed Behavior

Error 500 is raised:

netbox_1               | Internal Server Error: /dcim/rear-ports/33/trace/
netbox_1               | Traceback (most recent call last):
netbox_1               |   File "/opt/netbox/venv/lib/python3.9/site-packages/django/core/handlers/exception.py", line 47, in inner
netbox_1               |     response = get_response(request)
netbox_1               |   File "/opt/netbox/venv/lib/python3.9/site-packages/django/core/handlers/base.py", line 181, in _get_response
netbox_1               |     response = wrapped_callback(request, *callback_args, **callback_kwargs)
netbox_1               |   File "/opt/netbox/venv/lib/python3.9/site-packages/django/views/generic/base.py", line 70, in view
netbox_1               |     return self.dispatch(request, *args, **kwargs)
netbox_1               |   File "/opt/netbox/netbox/dcim/views.py", line 2392, in dispatch
netbox_1               |     return super().dispatch(request, *args, **kwargs)
netbox_1               |   File "/opt/netbox/netbox/utilities/views.py", line 93, in dispatch
netbox_1               |     return super().dispatch(request, *args, **kwargs)
netbox_1               |   File "/opt/netbox/venv/lib/python3.9/site-packages/django/views/generic/base.py", line 98, in dispatch
netbox_1               |     return handler(request, *args, **kwargs)
netbox_1               |   File "/opt/netbox/netbox/netbox/views/generic.py", line 71, in get
netbox_1               |     **self.get_extra_context(request, instance),
netbox_1               |   File "/opt/netbox/netbox/dcim/views.py", line 2418, in get_extra_context
netbox_1               |     api_viewname = f"{path.origin._meta.app_label}-api:{path.origin._meta.model_name}-trace"
netbox_1               | AttributeError: 'NoneType' object has no attribute 'origin'

If only one leg is connected to an interface the error will be:

netbox_1               | Internal Server Error: /api/dcim/interfaces/87/trace/
netbox_1               | Traceback (most recent call last):
netbox_1               |   File "/opt/netbox/venv/lib/python3.9/site-packages/django/core/handlers/exception.py", line 47, in inner
netbox_1               |     response = get_response(request)
netbox_1               |   File "/opt/netbox/venv/lib/python3.9/site-packages/django/core/handlers/base.py", line 181, in _get_response
netbox_1               |     response = wrapped_callback(request, *callback_args, **callback_kwargs)
netbox_1               |   File "/opt/netbox/venv/lib/python3.9/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
netbox_1               |     return view_func(*args, **kwargs)
netbox_1               |   File "/opt/netbox/venv/lib/python3.9/site-packages/rest_framework/viewsets.py", line 125, in view
netbox_1               |     return self.dispatch(request, *args, **kwargs)
netbox_1               |   File "/opt/netbox/netbox/netbox/api/views.py", line 201, in dispatch
netbox_1               |     return super().dispatch(request, *args, **kwargs)
netbox_1               |   File "/opt/netbox/venv/lib/python3.9/site-packages/rest_framework/views.py", line 509, in dispatch
netbox_1               |     response = self.handle_exception(exc)
netbox_1               |   File "/opt/netbox/venv/lib/python3.9/site-packages/rest_framework/views.py", line 469, in handle_exception
netbox_1               |     self.raise_uncaught_exception(exc)
netbox_1               |   File "/opt/netbox/venv/lib/python3.9/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
netbox_1               |     raise exc
netbox_1               |   File "/opt/netbox/venv/lib/python3.9/site-packages/rest_framework/views.py", line 506, in dispatch
netbox_1               |     response = handler(request, *args, **kwargs)
netbox_1               |   File "/opt/netbox/netbox/dcim/api/views.py", line 59, in trace
netbox_1               |     drawing = obj.get_trace_svg(
netbox_1               |   File "/opt/netbox/netbox/dcim/models/device_components.py", line 202, in get_trace_svg
netbox_1               |     return trace.render()
netbox_1               |   File "/opt/netbox/netbox/dcim/svg.py", line 438, in render
netbox_1               |     url=near_end.get_absolute_url(),
netbox_1               | AttributeError: 'NoneType' object has no attribute 'get_absolute_url'

Metadata

Metadata

Assignees

Labels

status: acceptedThis issue has been accepted for implementationtype: bugA confirmed report of unexpected behavior in the application

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions