From 1824f637b4c5135fdac4f76b1f44b852b3e038b4 Mon Sep 17 00:00:00 2001 From: Andreas Wrede Date: Tue, 5 May 2026 13:02:28 -0400 Subject: [PATCH] fix: always show THRESHOLD_DEFAULTS in Settings threshold config Seed threshold_configs["default"] from THRESHOLD_DEFAULTS at the start of _parse_config() so the Settings page displays built-in defaults regardless of whether the server config uses the multi-config format, the legacy thresholds: format, or has no threshold config at all. _parse_multi_config() overwrites the seed with the fully-merged effective defaults when a threshold_configs section is present. Co-Authored-By: Claude Sonnet 4.6 --- hbd/server/threshold.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/hbd/server/threshold.py b/hbd/server/threshold.py index 06125f9..ed6dad2 100644 --- a/hbd/server/threshold.py +++ b/hbd/server/threshold.py @@ -419,14 +419,28 @@ class ThresholdChecker: def _parse_config(self, config: Dict[str, Any]): """Parse threshold configuration from YAML structure. - + Supports two formats: 1. Legacy format with direct 'thresholds' section 2. New format with 'threshold_configs' and 'host_threshold_mapping' + + In all cases, THRESHOLD_DEFAULTS are seeded into threshold_configs["default"] + so the Settings page always shows the built-in defaults. + _parse_multi_config() overwrites this with the fully-merged effective defaults. """ + # Always expose built-in defaults through threshold_configs["default"] so + # the Settings page has something to display even in legacy/no-config mode. + seed: Dict[str, ThresholdConfig] = {} + for plugin_name, plugin_thresholds in THRESHOLD_DEFAULTS.get("thresholds", {}).items(): + if isinstance(plugin_thresholds, dict): + self._parse_plugin_thresholds(plugin_name, plugin_thresholds, target_dict=seed) + if seed: + self.threshold_configs["default"] = seed + self.threshold_raw_configs["default"] = {} + # Check for new multi-config format if "threshold_configs" in config: - self._parse_multi_config(config) + self._parse_multi_config(config) # overwrites threshold_configs["default"] elif "thresholds" in config: # Legacy single threshold configuration self._parse_legacy_config(config)