Path tracing error during bulk device deletion #7166

Closed
opened 2025-12-29 20:20:02 +01:00 by adam · 2 comments
Owner

Originally created by @kr3ator on GitHub (Oct 27, 2022).

NetBox version

v3.3.5

Python version

3.10

Steps to Reproduce

  1. Create any number of devices you like, e.g. dev-a, dev-b, dev-c.
  2. Create any number of cables between those devices (preferably a full mesh), e.g.:
    dev-a [eth0] <----> [eth0] dev-b
    dev-a [eth1] <----> [eth0] dev-c
    dev-b [eth1] <----> [eth1] dev-c
  3. Go to Netbox shell and do:
d = Device.objects.all() (or any filter that returns all of the devices from pt. 1)
d.delete()

Expected Behavior

All devices and cables between them have been deleted.

Observed Behavior

d.delete()
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/models/query.py", line 827, in delete
    deleted, _rows_count = collector.delete()
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/models/deletion.py", line 488, in delete
    signals.post_delete.send(
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/dispatch/dispatcher.py", line 176, in send
    return [
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/dispatch/dispatcher.py", line 177, in <listcomp>
    (receiver, receiver(signal=self, sender=sender, **named))
  File "/opt/netbox/netbox/dcim/signals.py", line 125, in nullify_connected_endpoints
    cablepath.retrace()
  File "/opt/netbox/netbox/dcim/models/cables.py", line 600, in retrace
    _new = self.from_origin(self.origins)
  File "/opt/netbox/netbox/dcim/models/cables.py", line 506, in from_origin
    local_cable_end = local_cable_terminations[0].cable_end
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/models/query.py", line 362, in __getitem__
    return qs._result_cache[0]
IndexError: list index out of range

However, doing this by selecting all devices via WebUI and then clicking delete works.

Originally created by @kr3ator on GitHub (Oct 27, 2022). ### NetBox version v3.3.5 ### Python version 3.10 ### Steps to Reproduce 1. Create any number of devices you like, e.g. dev-a, dev-b, dev-c. 2. Create any number of cables between those devices (preferably a full mesh), e.g.: dev-a [eth0] <----> [eth0] dev-b dev-a [eth1] <----> [eth0] dev-c dev-b [eth1] <----> [eth1] dev-c 3. Go to Netbox shell and do: ``` d = Device.objects.all() (or any filter that returns all of the devices from pt. 1) d.delete() ``` ### Expected Behavior All devices and cables between them have been deleted. ### Observed Behavior ```python d.delete() Traceback (most recent call last): File "<console>", line 1, in <module> File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/models/query.py", line 827, in delete deleted, _rows_count = collector.delete() File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/models/deletion.py", line 488, in delete signals.post_delete.send( File "/opt/netbox/venv/lib/python3.10/site-packages/django/dispatch/dispatcher.py", line 176, in send return [ File "/opt/netbox/venv/lib/python3.10/site-packages/django/dispatch/dispatcher.py", line 177, in <listcomp> (receiver, receiver(signal=self, sender=sender, **named)) File "/opt/netbox/netbox/dcim/signals.py", line 125, in nullify_connected_endpoints cablepath.retrace() File "/opt/netbox/netbox/dcim/models/cables.py", line 600, in retrace _new = self.from_origin(self.origins) File "/opt/netbox/netbox/dcim/models/cables.py", line 506, in from_origin local_cable_end = local_cable_terminations[0].cable_end File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/models/query.py", line 362, in __getitem__ return qs._result_cache[0] IndexError: list index out of range ``` However, doing this by selecting all devices via WebUI and then clicking delete works.
adam added the type: bug label 2025-12-29 20:20:02 +01:00
adam closed this issue 2025-12-29 20:20:02 +01:00
Author
Owner

@jeremystretch commented on GitHub (Oct 27, 2022):

  1. Create couple of devices and interconnect them with multiple cables.

I'm going to close this as you haven't put any effort into providing detailed reproduction steps per the template. If you'd like to rewrite your original issue so that it meets the requirements for a bug report, I'll be happy to reopen this.

@jeremystretch commented on GitHub (Oct 27, 2022): > 1. Create couple of devices and interconnect them with multiple cables. I'm going to close this as you haven't put any effort into providing detailed reproduction steps per the template. If you'd like to rewrite your original issue so that it meets the requirements for a bug report, I'll be happy to reopen this.
Author
Owner

@kr3ator commented on GitHub (Oct 27, 2022):

  1. Create couple of devices and interconnect them with multiple cables.

I'm going to close this as you haven't put any effort into providing detailed reproduction steps per the template. If you'd like to rewrite your original issue so that it meets the requirements for a bug report, I'll be happy to reopen this.

I just sticked to the bare minimum to reproduce as it doesn't matter which interfaces you connect as long as all devices are interconnected with each other. I've made the reproduction steps more verbose now.

@jeremystretch could you please re-open this?

@kr3ator commented on GitHub (Oct 27, 2022): > > 1. Create couple of devices and interconnect them with multiple cables. > > I'm going to close this as you haven't put any effort into providing detailed reproduction steps per the template. If you'd like to rewrite your original issue so that it meets the requirements for a bug report, I'll be happy to reopen this. I just sticked to the bare minimum to reproduce as it doesn't matter which interfaces you connect as long as all devices are interconnected with each other. I've made the reproduction steps more verbose now. @jeremystretch could you please re-open this?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#7166