From 4c481caf445d8627d25edbb305f18cfeba9e9ea5 Mon Sep 17 00:00:00 2001 From: Andreas Motl Date: Sun, 27 Jul 2025 15:01:50 +0200 Subject: [PATCH] Fix 404 error on "dash-folder" type when enumerating dashboards --- CHANGES.rst | 2 ++ grafana_wtf/core.py | 2 ++ tests/test_commands.py | 5 ++--- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index e1c3082..bf93aa1 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -5,6 +5,8 @@ grafana-wtf changelog in progress =========== +- Fixed 404 error on "dash-folder" type when enumerating dashboards. + Thanks, @oxy-star and @GarbageYard. 2025-03-18 0.23.0 ================= diff --git a/grafana_wtf/core.py b/grafana_wtf/core.py index 47cd336..2aa804b 100644 --- a/grafana_wtf/core.py +++ b/grafana_wtf/core.py @@ -260,6 +260,8 @@ def fetch_dashboards(self): log.info("Fetching dashboards one by one") results = self.data.dashboard_list for dashboard_info in results: + if dashboard_info.get("type") == "dash-folder": + continue self.fetch_dashboard(dashboard_info) def fetch_dashboards_parallel(self): diff --git a/tests/test_commands.py b/tests/test_commands.py index 601d323..b7c541a 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -313,7 +313,7 @@ def test_log_all(ldi_resources, capsys, caplog): # Verify output. assert "Aggregating edit history for multiple Grafana dashboards" in caplog.text history = json.loads(captured.out) - assert len(history) == 3 + assert len(history) == 2 def test_log_json_success(ldi_resources, capsys, caplog): @@ -400,7 +400,7 @@ def test_log_yaml_success(ldi_resources, capsys, caplog): data = yaml.safe_load(captured.out) - assert len(data) == 3 + assert len(data) == 2 def test_log_filter_sql(ldi_resources, capsys, caplog): @@ -429,7 +429,6 @@ def test_log_filter_sql(ldi_resources, capsys, caplog): assert set(captured.out.strip().split("\n")) == { "- url: http://localhost:33333/d/ioUrPwQiz/luftdaten-info-generic-trend-v27", "- url: http://localhost:33333/d/jpVsQxRja/luftdaten-info-generic-trend-v33", - "- url: http://localhost:33333/dashboards/f/testdrive/testdrive", }