From 5b2fc8fd46e14ada0115eb318ec5a3150fcb98fd Mon Sep 17 00:00:00 2001 From: Andreas Wrede Date: Mon, 17 Aug 2026 07:25:17 -0400 Subject: [PATCH] fix: hide synthetic rtt history keys from plugin accordion list --- hbd/server/http.py | 12 +++++++++++- tests/test_http_plugins_page.py | 23 +++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 tests/test_http_plugins_page.py diff --git a/hbd/server/http.py b/hbd/server/http.py index 2005ea8..c819529 100644 --- a/hbd/server/http.py +++ b/hbd/server/http.py @@ -210,6 +210,16 @@ def _mask_config_for_api(config) -> dict: return result +def _visible_plugin_names(plugin_data: dict) -> list: + """Plugin names to render as accordion sections. + + Excludes synthetic rtt_ipv4 / rtt_ipv6 history streams (written by + udp.py for charting) which aren't real client plugins and have no + accordion renderer. + """ + return [p for p in plugin_data.keys() if not p.startswith("rtt_")] + + def _build_host_info(host, threshold_checker=None) -> dict: """Assemble the info payload for GET /api/0/hosts/{hostname}/info.""" hbc_version = None @@ -767,7 +777,7 @@ async def start( if host.plugin_data: hosts_with_plugins.append({ "name": hostname, - "plugins": list(host.plugin_data.keys()), + "plugins": _visible_plugin_names(host.plugin_data), "is_owner": _can_own_host(current_user, host), "owner": host.owner, }) diff --git a/tests/test_http_plugins_page.py b/tests/test_http_plugins_page.py new file mode 100644 index 0000000..e130498 --- /dev/null +++ b/tests/test_http_plugins_page.py @@ -0,0 +1,23 @@ +"""Tests for the plugin-accordion visibility filter in http.py.""" +from hbd.server.http import _visible_plugin_names + + +def test_visible_plugin_names_excludes_rtt_history_keys(): + plugin_data = { + "cpu_monitor": [], + "rtt_ipv4": [], + "rtt_ipv6": [], + "network_monitor": [], + } + result = _visible_plugin_names(plugin_data) + assert sorted(result) == ["cpu_monitor", "network_monitor"] + + +def test_visible_plugin_names_empty_when_no_plugins(): + assert _visible_plugin_names({}) == [] + + +def test_visible_plugin_names_keeps_names_not_prefixed_with_rtt_(): + plugin_data = {"nagios_runner": [], "os_info": []} + result = _visible_plugin_names(plugin_data) + assert sorted(result) == ["nagios_runner", "os_info"]