fix(gateway): honor explicit msgraph_webhook disable under env override

Sibling of the webhook branch fixed in the previous commit (#85637): the
MSGRAPH_WEBHOOK env-override branch force-set enabled=True whenever
MSGRAPH_WEBHOOK_ENABLED was truthy, ignoring an explicit
`platforms.msgraph_webhook.enabled: false` in config.yaml. Apply the same
_enabled_explicit guard; port/client_state extras still wire through.
This commit is contained in:
Teknium
2026-09-02 03:36:49 -07:00
parent dd666d2418
commit 64bbbaa896
2 changed files with 16 additions and 1 deletions
+7 -1
View File
@@ -2448,7 +2448,13 @@ def _apply_env_overrides(config: GatewayConfig) -> None:
if Platform.MSGRAPH_WEBHOOK not in config.platforms:
config.platforms[Platform.MSGRAPH_WEBHOOK] = PlatformConfig()
if msgraph_webhook_enabled:
config.platforms[Platform.MSGRAPH_WEBHOOK].enabled = True
# Same explicit-disable guard as the webhook branch above (#85637).
# READ (don't pop) the marker here: the relay-exclusive pass below
# still consults it, and the end-of-function scrub removes it for
# every platform.
msgraph_cfg = config.platforms[Platform.MSGRAPH_WEBHOOK]
if not msgraph_cfg.extra.get("_enabled_explicit", False) or msgraph_cfg.enabled:
msgraph_cfg.enabled = True
if msgraph_webhook_port:
try:
config.platforms[Platform.MSGRAPH_WEBHOOK].extra["port"] = int(
+9
View File
@@ -1426,6 +1426,7 @@ class TestWebhookEnvOverride:
The fix honors the explicit disable, flagged by ``_enabled_explicit``
in the platform's extra (set when the config.yaml pins enabled).
The MSGRAPH_WEBHOOK branch shares the shape and the fix.
"""
config = GatewayConfig(
platforms={
@@ -1433,6 +1434,10 @@ class TestWebhookEnvOverride:
enabled=False,
extra={"_enabled_explicit": True},
),
Platform.MSGRAPH_WEBHOOK: PlatformConfig(
enabled=False,
extra={"_enabled_explicit": True},
),
},
)
@@ -1442,6 +1447,8 @@ class TestWebhookEnvOverride:
"WEBHOOK_ENABLED": "true",
"WEBHOOK_PORT": "9999",
"WEBHOOK_SECRET": "shared-secret",
"MSGRAPH_WEBHOOK_ENABLED": "true",
"MSGRAPH_WEBHOOK_PORT": "9998",
},
clear=True,
):
@@ -1449,6 +1456,8 @@ class TestWebhookEnvOverride:
# Explicit disable wins over the env-var presence.
assert config.platforms[Platform.WEBHOOK].enabled is False
assert config.platforms[Platform.MSGRAPH_WEBHOOK].enabled is False
assert config.platforms[Platform.MSGRAPH_WEBHOOK].extra.get("port") == 9998
# Port/secret are still wired through for the shared listener.
assert config.platforms[Platform.WEBHOOK].extra.get("port") == 9999
assert (