fix(gateway): bridge gateway_restart_notification from YAML platform sections

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.
This commit is contained in:
colin-chang 2026-05-18 20:04:02 -07:00 committed by Teknium
parent 2b538c1f4e
commit 7a46c68857

View file

@ -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