From 4d119bb62acddf75669d3a5c79e3cc5b40d93a05 Mon Sep 17 00:00:00 2001 From: Teknium Date: Sun, 26 Apr 2026 12:23:05 -0700 Subject: [PATCH] test: blank platform-gating env vars in hermetic fixture load_gateway_config() has a side effect: when config.yaml contains platform-gating keys (slack.require_mention, slack.strict_mention, slack.free_response_channels, slack.allow_bots, slack.reactions, plus analogous keys for discord/telegram/whatsapp/dingtalk/matrix), it calls os.environ[KEY] = ... to bridge them to env-var form. monkeypatch.delenv doesn't track direct os.environ mutations made inside the test body, so tests that call load_gateway_config() leak those env vars into later tests on the same xdist worker. The failure mode is flaky seed-dependent: test_top_level_message_requires_mention_ even_with_session (and siblings in TestThreadReplyHandling) pass when SLACK_REQUIRE_MENTION is unset but fail when a leaked value of 'false' is present. Add the gating env vars to _HERMES_BEHAVIORAL_VARS so the hermetic autouse fixture blanks them on every test setup, closing the leak regardless of which test sets them. --- tests/conftest.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/conftest.py b/tests/conftest.py index 0258e034f9..844138f66e 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -211,6 +211,21 @@ _HERMES_BEHAVIORAL_VARS = frozenset({ "SIGNAL_ALLOW_ALL_USERS", "EMAIL_ALLOW_ALL_USERS", "SMS_ALLOW_ALL_USERS", + # Platform gating — set by load_gateway_config() as a side effect when + # a config.yaml is present, so individual test bodies that call the + # loader leak these values into later tests on the same xdist worker. + # Force-clear on every test setup so the leak can't happen. + "SLACK_REQUIRE_MENTION", + "SLACK_STRICT_MENTION", + "SLACK_FREE_RESPONSE_CHANNELS", + "SLACK_ALLOW_BOTS", + "SLACK_REACTIONS", + "DISCORD_REQUIRE_MENTION", + "DISCORD_FREE_RESPONSE_CHANNELS", + "TELEGRAM_REQUIRE_MENTION", + "WHATSAPP_REQUIRE_MENTION", + "DINGTALK_REQUIRE_MENTION", + "MATRIX_REQUIRE_MENTION", })