Skip to content

The agent that grows with you

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

Teknium64bbbaa89643
diff --git a/gateway/config.py b/gateway/config.py
index c9108614dcf..49b405fc029 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 b06b163bdb7..480e26d48c9 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 (