From ad91f8ec8dd811cbd04699fcfd698c6400994e3c Mon Sep 17 00:00:00 2001 From: Valentijn Scholten Date: Mon, 22 Jun 2026 19:29:49 +0200 Subject: [PATCH 1/2] fix(metrics): prevent 500 on Critical Asset Metrics page when no critical products exist (#15051) When no product types are marked critical, the empty critical_prods queryset is falsy, so the metrics template fell through its '{% if not critical_prods %}' general-dashboard branch, which references context (max_findings_details, findings, ...) that the critical_product_metrics view does not supply, raising VariableDoesNotExist for 'max_findings_details'. Gate the dashboard branches on 'name != labels.ASSET_METRICS_CRITICAL_LABEL' too, mirroring the existing header branch, so the critical asset page shows the 'no critical assets' message instead of the general dashboard. Applied to both the V3 and classic metrics templates. Co-Authored-By: Claude Opus 4.8 --- dojo/templates/dojo/metrics.html | 4 ++-- dojo/templates_classic/dojo/metrics.html | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dojo/templates/dojo/metrics.html b/dojo/templates/dojo/metrics.html index 2c7ab40fbf6..b35c7bb24ee 100644 --- a/dojo/templates/dojo/metrics.html +++ b/dojo/templates/dojo/metrics.html @@ -360,7 +360,7 @@

{% trans "Risk accepted bug count by month" %} {% endif %} - {% if not critical_prods %} + {% if not critical_prods and name != labels.ASSET_METRICS_CRITICAL_LABEL %}
@@ -943,7 +943,7 @@

{% trans "Closed in Period" %}

medium1.push([{{ week.epoch }}, {{ week.medium }}]); low1.push([{{ week.epoch }}, {{ week.low }}]); {% endfor %} - {% if not critical_prods %} + {% if not critical_prods and name != labels.ASSET_METRICS_CRITICAL_LABEL %} opened_per_week_2(critical, high, medium, low); accepted_per_week_2(critical1, high1, medium1, low1); {% endif %} diff --git a/dojo/templates_classic/dojo/metrics.html b/dojo/templates_classic/dojo/metrics.html index 777467e0e59..881abbef4cb 100644 --- a/dojo/templates_classic/dojo/metrics.html +++ b/dojo/templates_classic/dojo/metrics.html @@ -368,7 +368,7 @@

{% trans "Risk accepted bug count by month" %}

{% endif %} - {% if not critical_prods %} + {% if not critical_prods and name != labels.ASSET_METRICS_CRITICAL_LABEL %}
@@ -958,7 +958,7 @@

{% trans "Closed in Period" %}

medium1.push([{{ week.epoch }}, {{ week.medium }}]); low1.push([{{ week.epoch }}, {{ week.low }}]); {% endfor %} - {% if not critical_prods %} + {% if not critical_prods and name != labels.ASSET_METRICS_CRITICAL_LABEL %} opened_per_week_2(critical, high, medium, low); accepted_per_week_2(critical1, high1, medium1, low1); {% endif %} From fa3cf5d140613c968388de2a3656eba4ec2ce231 Mon Sep 17 00:00:00 2001 From: Valentijn Scholten Date: Mon, 22 Jun 2026 19:53:03 +0200 Subject: [PATCH 2/2] test(e2e): smoke-check /critical_asset_metrics page loads (#15051) Co-Authored-By: Claude Opus 4.8 --- tests/check_various_pages.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/check_various_pages.py b/tests/check_various_pages.py index aa1188253cc..d03ec3e0cd5 100644 --- a/tests/check_various_pages.py +++ b/tests/check_various_pages.py @@ -10,6 +10,10 @@ def test_user_status(self): driver = self.driver driver.get(self.base_url + "user") + def test_critical_asset_metrics_status(self): + driver = self.driver + driver.get(self.base_url + "critical_asset_metrics") + def test_calendar_status(self): driver = self.driver driver.get(self.base_url + "calendar") @@ -42,6 +46,7 @@ def suite(): suite = unittest.TestSuite() suite.addTest(BaseTestCase("test_login")) suite.addTest(VariousPagesTest("test_user_status")) + suite.addTest(VariousPagesTest("test_critical_asset_metrics_status")) suite.addTest(VariousPagesTest("test_calendar_status")) suite.addTest(VariousPagesTest("test_finding_group_open_status")) suite.addTest(VariousPagesTest("test_finding_group_all_status"))