From 7a46c68857367e5eb4bc1dfe8838eea6d5c93c50 Mon Sep 17 00:00:00 2001 From: colin-chang <24368158+colin-chang@users.noreply.github.com> Date: Mon, 18 May 2026 20:04:02 -0700 Subject: [PATCH] fix(gateway): bridge gateway_restart_notification from YAML platform sections MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two related bugs in gateway/config.py prevented per-platform gateway_restart_notification from working through config.yaml: 1. The shared-key bridging loop (load_gateway_config) omitted 'gateway_restart_notification', so the key never landed in platform_data['extra'] even when set under e.g. 'discord:' or 'mattermost:' sections. 2. PlatformConfig.from_dict() only read gateway_restart_notification from the top-level data dict, ignoring the 'extra' sub-dict where bridged keys are stored. Fix: add the key to the bridging loop, and add an 'extra' fallback in from_dict() so that round-tripped values (YAML → bridged → extra → from_dict) resolve correctly. Impact: users can now set gateway_restart_notification: false per platform in config.yaml instead of relying on env vars or the global platforms: block. --- gateway/config.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/gateway/config.py b/gateway/config.py index 7180f1ddb84..bdf5ede52d7 100644 --- a/gateway/config.py +++ b/gateway/config.py @@ -322,15 +322,21 @@ class PlatformConfig: if "home_channel" in data: home_channel = HomeChannel.from_dict(data["home_channel"]) + # gateway_restart_notification may be bridged into extra via the + # shared-key loop in load_gateway_config(); check both top-level + # and extra so YAML ``discord: gateway_restart_notification: false`` + # works without needing a separate platforms: block. + _grn = data.get("gateway_restart_notification") + if _grn is None: + _grn = data.get("extra", {}).get("gateway_restart_notification") + return cls( enabled=_coerce_bool(data.get("enabled"), False), token=data.get("token"), api_key=data.get("api_key"), home_channel=home_channel, reply_to_mode=data.get("reply_to_mode", "first"), - gateway_restart_notification=_coerce_bool( - data.get("gateway_restart_notification"), True - ), + gateway_restart_notification=_coerce_bool(_grn, True), extra=data.get("extra", {}), ) @@ -849,6 +855,8 @@ def load_gateway_config() -> GatewayConfig: bridged["channel_prompts"] = {str(k): v for k, v in channel_prompts.items()} else: bridged["channel_prompts"] = channel_prompts + if "gateway_restart_notification" in platform_cfg: + bridged["gateway_restart_notification"] = platform_cfg["gateway_restart_notification"] enabled_was_explicit = "enabled" in platform_cfg if not bridged and not enabled_was_explicit: continue