From aa05097fcaa1ecc8c812c57158b0e111858c3b58 Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Thu, 16 Sep 2021 08:56:26 -0400 Subject: [PATCH] Fixes #7279: Fix exception when tracing cable with no associated path --- docs/release-notes/version-3.0.md | 1 + netbox/dcim/views.py | 6 ++++++ netbox/templates/dcim/cable_trace.html | 13 +++++++++++-- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/docs/release-notes/version-3.0.md b/docs/release-notes/version-3.0.md index 16d1d773d..9288425b5 100644 --- a/docs/release-notes/version-3.0.md +++ b/docs/release-notes/version-3.0.md @@ -15,6 +15,7 @@ * [#7167](https://github.com/netbox-community/netbox/issues/7167) - Ensure consistent font size when using monospace formatting * [#7226](https://github.com/netbox-community/netbox/issues/7226) - Exempt GraphQL API requests from CSRF inspection * [#7248](https://github.com/netbox-community/netbox/issues/7248) - Fix global search results section links +* [#7279](https://github.com/netbox-community/netbox/issues/7279) - Fix exception when tracing cable with no associated path --- diff --git a/netbox/dcim/views.py b/netbox/dcim/views.py index cb0e089cf..f9e1cc9fe 100644 --- a/netbox/dcim/views.py +++ b/netbox/dcim/views.py @@ -2411,6 +2411,12 @@ class PathTraceView(generic.ObjectView): else: path = related_paths.first() + # No paths found + if path is None: + return { + 'path': None + } + # Get the total length of the cable and whether the length is definitive (fully defined) total_length, is_definitive = path.get_total_length() if path else (None, False) diff --git a/netbox/templates/dcim/cable_trace.html b/netbox/templates/dcim/cable_trace.html index 4e82568b7..d9dbc5b2d 100644 --- a/netbox/templates/dcim/cable_trace.html +++ b/netbox/templates/dcim/cable_trace.html @@ -5,7 +5,10 @@ {% block content %}
+ + {# Cable trace SVG & options #} -
+ {# Related paths #} +
Related Paths @@ -95,7 +104,7 @@
-
+
{% endblock %}