From 83bb19a7b4fc6bb97ef743d33042c237523f11ac Mon Sep 17 00:00:00 2001 From: Martin Hauser Date: Wed, 1 Apr 2026 13:47:11 +0200 Subject: [PATCH] fix(dcim): Handle missing Virtual Circuit Termination gracefully Replace direct attribute access with try-except to catch ObjectDoesNotExist when virtual_circuit_termination relation is missing. Prevents errors when rendering Virtual Circuits Panel with broken or missing terminations. Fixes #21808 --- netbox/dcim/ui/panels.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/netbox/dcim/ui/panels.py b/netbox/dcim/ui/panels.py index f75e3d478..8cfb523f7 100644 --- a/netbox/dcim/ui/panels.py +++ b/netbox/dcim/ui/panels.py @@ -1,4 +1,5 @@ from django.contrib.contenttypes.models import ContentType +from django.core.exceptions import ObjectDoesNotExist from django.template.loader import render_to_string from django.utils.translation import gettext_lazy as _ @@ -532,8 +533,14 @@ class VirtualCircuitPanel(panels.ObjectPanel): def render(self, context): obj = context.get('object') - if not obj or not obj.is_virtual or not obj.virtual_circuit_termination: + if not obj or not obj.is_virtual: return '' + + try: + obj.virtual_circuit_termination + except ObjectDoesNotExist: + return '' + ctx = self.get_context(context) return render_to_string(self.template_name, ctx, request=ctx.get('request'))