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

Cable Trace leads to "division by zero" if the last cable is not connected #17868

Closed
knebb opened this issue Oct 27, 2024 · 5 comments · Fixed by #18244
Closed

Cable Trace leads to "division by zero" if the last cable is not connected #17868

knebb opened this issue Oct 27, 2024 · 5 comments · Fixed by #18244
Assignees
Labels
netbox severity: low Does not significantly disrupt application functionality, or a workaround is available status: accepted This issue has been accepted for implementation topic: cabling type: bug A confirmed report of unexpected behavior in the application

Comments

@knebb
Copy link

knebb commented Oct 27, 2024

Deployment Type

Self-hosted

Triage priority

N/A

NetBox Version

NetBox Community v4.1.3

Python Version

3.11

Steps to Reproduce

Have a switch (or similar) with an interface connected through multiple passive components (ie patchpanel, wall-plugs) to a device with an interface.
From switch, do cable trace on this interface - it will display all in-between interfaces (as expected).
Delete the device without deleting or disconnecting its cable will result in an unterminated cable (might be by design).
Trace the cable again from the switch interface.

Expected Behavior

I expect the cable trace to walk through until the last (unterminated) cable and show either the last device or the unterminated cable to trace down the still existing cables.

Observed Behavior

Results in an error without displaying any svg cable date:

<class 'ZeroDivisionError'>

division by zero

Python-Version: 3.11.2
NetBox-Version: 4.1.3
Plugins: 
  netbox_topology_views: 4.0.1
@knebb knebb added status: needs triage This issue is awaiting triage by a maintainer type: bug A confirmed report of unexpected behavior in the application labels Oct 27, 2024
@arthanson
Copy link
Collaborator

@knebb Thank you for opening a bug report. Unfortunately, the information you have provided is not sufficient for someone else to attempt to reproduce the reported behavior. Remember, each bug report must include detailed steps that someone else can follow on a clean, empty NetBox installation to reproduce the exact problem you're experiencing. These instructions should include the creation of any involved objects, any configuration changes, and complete accounting of the actions being taken. Also be sure that your report does not reference data on the public NetBox demo, as that is subject to change at any time by an outside party and cannot be relied upon for bug reports.

Can you please provide complete reproduction steps, something like:

  1. create device A with name=xxx,
  2. Add interface 1 to device A
  3. ...
  4. Connect cable to interface 1 to ...
  5. Click the cable trace button and see the error.

@arthanson arthanson added status: revisions needed This issue requires additional information to be actionable and removed status: needs triage This issue is awaiting triage by a maintainer labels Oct 29, 2024
@knebb
Copy link
Author

knebb commented Oct 29, 2024

Hi,

I though it is indeed self explanatory. However; I will try again:

Create a "switch" A with at least a single interface (switches usually have multiple...).
Create at least one device B with a frontport and a rearport.
Create another device C with at least one interface (like a PC or something).

Connect one interface from the switch A to rearport of B.
Connect frontport of B with interface of C.

Go to the "Interfaces" page of switch A. Select the "Trace" button of the interface you connected with the above steps.
You will get the cable trace in SVG format and at the bottom you will see device C.

Go to devices and delete device C. Do NOT delete or edit the cables from above steps!
You will end up with an orphaned cable (which will not do any harm).

Go again to the "Interfaces" page of the switch A. Klick on the "Trace" button again. Instead of showing the connected trace through B to the orphaned cable you will get no SVG graphic.

Click on the Download SVG button and you will get an "Server error" with the "Division by zero" error I mentioned.

I (And others) do not mind about the orphan cable. But it should show the SVG graph to the last connected device. Otherwise I am not able to track or trace where the connected interface of the switch ends.

Hope it's clear now.

@jeremystretch jeremystretch added the netbox label Nov 1, 2024 — with Linear
Copy link
Contributor

github-actions bot commented Nov 9, 2024

This is a reminder that additional information is needed in order to further triage this issue. If the requested details are not provided, the issue will soon be closed automatically.

@github-actions github-actions bot added the pending closure Requires immediate attention to avoid being closed for inactivity label Nov 9, 2024
@knebb
Copy link
Author

knebb commented Nov 9, 2024

@arthanson
I added the required information (see above). What else can I do?

@jeremystretch
Copy link
Member

I was able to reproduce this on NetBox v4.1.7. Stack trace below.

Internal Server Error: /api/dcim/interfaces/1620/trace/
Traceback (most recent call last):
  File "/home/jstretch/projects/netbox/venv/lib/python3.10/site-packages/django/core/handlers/exception.py", line 55, in inner
    response = get_response(request)
  File "/home/jstretch/projects/netbox/venv/lib/python3.10/site-packages/django/core/handlers/base.py", line 197, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/jstretch/projects/netbox/venv/lib/python3.10/site-packages/django/views/decorators/csrf.py", line 65, in _view_wrapper
    return view_func(request, *args, **kwargs)
  File "/home/jstretch/projects/netbox/venv/lib/python3.10/site-packages/rest_framework/viewsets.py", line 124, in view
    return self.dispatch(request, *args, **kwargs)
  File "/home/jstretch/projects/netbox/netbox/netbox/api/viewsets/__init__.py", line 135, in dispatch
    return super().dispatch(request, *args, **kwargs)
  File "/home/jstretch/projects/netbox/venv/lib/python3.10/site-packages/rest_framework/views.py", line 509, in dispatch
    response = self.handle_exception(exc)
  File "/home/jstretch/projects/netbox/venv/lib/python3.10/site-packages/rest_framework/views.py", line 469, in handle_exception
    self.raise_uncaught_exception(exc)
  File "/home/jstretch/projects/netbox/venv/lib/python3.10/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
    raise exc
  File "/home/jstretch/projects/netbox/venv/lib/python3.10/site-packages/rest_framework/views.py", line 506, in dispatch
    response = handler(request, *args, **kwargs)
  File "/home/jstretch/projects/netbox/netbox/dcim/api/views.py", line 55, in trace
    return HttpResponse(drawing.render().tostring(), content_type='image/svg+xml')
  File "/home/jstretch/projects/netbox/netbox/dcim/svg/cables.py", line 368, in render
    parent_object_nodes, far_terminations = self.draw_far_objects(obj_list, far_ends)
  File "/home/jstretch/projects/netbox/netbox/dcim/svg/cables.py", line 273, in draw_far_objects
    width = self.width / len(objects)
ZeroDivisionError: division by zero

@jeremystretch jeremystretch added status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation severity: low Does not significantly disrupt application functionality, or a workaround is available and removed status: revisions needed This issue requires additional information to be actionable pending closure Requires immediate attention to avoid being closed for inactivity labels Dec 6, 2024
@bctiemann bctiemann self-assigned this Dec 17, 2024
@bctiemann bctiemann added status: accepted This issue has been accepted for implementation topic: cabling and removed status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation labels Dec 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
netbox severity: low Does not significantly disrupt application functionality, or a workaround is available status: accepted This issue has been accepted for implementation topic: cabling type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants