From 4b7f9a4d304833f9af14c93466b7312b1cd35ff1 Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Sat, 20 Jun 2026 21:22:11 -0700 Subject: [PATCH] test(matrix): make voice-detection tests hermetic against mention gating (#49946) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit test_matrix_voice flaked in CI (6/7 failing on some shards, passing on others and on main) depending on leaked MATRIX_REQUIRE_MENTION env state. Root cause: the adapter defaults require_mention=True (falling back to the MATRIX_REQUIRE_MENTION env var). These tests fire a group-room audio event with no @mention, so _resolve_message_context drops it before dispatch ('No event was captured') whenever require_mention resolves True — which happens in a clean shard, but an earlier test in another shard can leave MATRIX_REQUIRE_MENTION=false in os.environ and mask it. The plugin migration (#5600105478 adapter→bundled plugin) shifted shard composition and exposed it. Pin require_mention: False in the test adapter config so these media-TYPE detection tests are no longer gated by the mention requirement, regardless of ambient env. Verified: 7/7 pass with MATRIX_REQUIRE_MENTION=true (the failing condition) AND with the env unset. --- tests/gateway/test_matrix_voice.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/gateway/test_matrix_voice.py b/tests/gateway/test_matrix_voice.py index 2e1cdc0befa54..b113ba275cafd 100644 --- a/tests/gateway/test_matrix_voice.py +++ b/tests/gateway/test_matrix_voice.py @@ -26,7 +26,16 @@ from gateway.platforms.base import MessageType # --------------------------------------------------------------------------- def _make_adapter(): - """Create a MatrixAdapter with mocked config.""" + """Create a MatrixAdapter with mocked config. + + Pins ``require_mention: False`` so these media-detection tests are NOT + gated by the mention requirement. The adapter defaults require_mention to + True (falling back to the MATRIX_REQUIRE_MENTION env var), so without this + a group-room audio event with no @mention is dropped by + _resolve_message_context before dispatch — making the tests pass or fail + depending on leaked env state from other tests in the same shard. These + tests exercise voice/audio TYPE detection, not mention gating. + """ from plugins.platforms.matrix.adapter import MatrixAdapter from gateway.config import PlatformConfig @@ -36,6 +45,7 @@ def _make_adapter(): extra={ "homeserver": "https://matrix.example.org", "user_id": "@bot:example.org", + "require_mention": False, }, ) adapter = MatrixAdapter(config)