Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions netbox/dcim/models/cables.py
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,10 @@ def from_origin(cls, terminations):
cable_end = 'A' if lct.cable_end == 'B' else 'B'
q_filter |= Q(cable=lct.cable, cable_end=cable_end)

# Make sure this filter has been populated; if not, we have probably been given invalid data
if not q_filter:
break

remote_cable_terminations = CableTermination.objects.filter(q_filter)
remote_terminations = [ct.termination for ct in remote_cable_terminations]
else:
Expand Down
3 changes: 2 additions & 1 deletion netbox/dcim/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ def update_connected_endpoints(instance, created, raw=False, **kwargs):
if instance._terminations_modified:
a_terminations = []
b_terminations = []
for t in instance.terminations.all():
# Note: instance.terminations.all() is not safe to use here as it might be stale
for t in CableTermination.objects.filter(cable=instance):
if t.cable_end == CableEndChoices.SIDE_A:
a_terminations.append(t.termination)
else:
Expand Down
Loading