From d5468cc573dd5449b344bb327ed5896bd5302a37 Mon Sep 17 00:00:00 2001 From: Brian Tiemann Date: Mon, 30 Dec 2024 13:06:19 -0500 Subject: [PATCH] Add defensive break if q_filter has not been populated --- netbox/dcim/models/cables.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/netbox/dcim/models/cables.py b/netbox/dcim/models/cables.py index 2a4748610..2bdaa50eb 100644 --- a/netbox/dcim/models/cables.py +++ b/netbox/dcim/models/cables.py @@ -607,6 +607,10 @@ class CablePath(models.Model): 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: