From 64bbbaa896434e02fc9ca3f51e5f03d9b14c08f1 Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Wed, 2 Sep 2026 03:36:49 -0700 Subject: [PATCH] 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. --- gateway/config.py | 8 +++++++- tests/gateway/test_config.py | 9 +++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/gateway/config.py b/gateway/config.py index c9108614dc..49b405fc02 100644 --- a/gateway/config.py +++ b/gateway/config.py @@ -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( diff --git a/tests/gateway/test_config.py b/tests/gateway/test_config.py index b06b163bdb..480e26d48c 100644 --- a/tests/gateway/test_config.py +++ b/tests/gateway/test_config.py @@ -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 (