From 1179918746a7df85399f4727a3aa44b5c307b9a9 Mon Sep 17 00:00:00 2001 From: Teknium Date: Sun, 12 Apr 2026 13:02:55 -0700 Subject: [PATCH] fix: salvage follow-ups for Feishu QR onboarding (#7706) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Remove duplicate _setup_feishu() definition (old 3-line version left behind by cherry-pick — Python picked the new one but dead code remained) - Remove misleading 'Disable direct messages' DM option — the Feishu adapter has no DM policy mechanism, so 'disable' produced identical env vars to 'pairing'. Users who chose 'disable' would still see pairing prompts. Reduced to 3 options: pairing, allow-all, allowlist. - Fix test_probe_returns_bot_info_on_success and test_probe_returns_none_on_failure: patch FEISHU_AVAILABLE=True so probe_bot() takes the SDK path when lark_oapi is not installed --- hermes_cli/gateway.py | 13 +------------ tests/gateway/test_feishu_onboard.py | 2 ++ tests/gateway/test_setup_feishu.py | 5 ----- 3 files changed, 3 insertions(+), 17 deletions(-) diff --git a/hermes_cli/gateway.py b/hermes_cli/gateway.py index a0a4d6735..8cdb856c9 100644 --- a/hermes_cli/gateway.py +++ b/hermes_cli/gateway.py @@ -2100,12 +2100,6 @@ def _setup_dingtalk(): _setup_standard_platform(dingtalk_platform) -def _setup_feishu(): - """Configure Feishu / Lark via the standard platform setup.""" - feishu_platform = next(p for p in _PLATFORMS if p["key"] == "feishu") - _setup_standard_platform(feishu_platform) - - def _setup_wecom(): """Configure WeCom (Enterprise WeChat) via the standard platform setup.""" wecom_platform = next(p for p in _PLATFORMS if p["key"] == "wecom") @@ -2415,7 +2409,6 @@ def _setup_feishu(): "Use DM pairing approval (recommended)", "Allow all direct messages", "Only allow listed user IDs", - "Disable direct messages", ] access_idx = prompt_choice(" How should direct messages be authorized?", access_choices, 0) if access_idx == 0: @@ -2427,16 +2420,12 @@ def _setup_feishu(): save_env_value("FEISHU_ALLOW_ALL_USERS", "true") save_env_value("FEISHU_ALLOWED_USERS", "") print_warning(" Open DM access enabled for Feishu / Lark.") - elif access_idx == 2: + else: save_env_value("FEISHU_ALLOW_ALL_USERS", "false") default_allow = open_id or "" allowlist = prompt(" Allowed user IDs (comma-separated)", default_allow, password=False).replace(" ", "") save_env_value("FEISHU_ALLOWED_USERS", allowlist) print_success(" Allowlist saved.") - else: - save_env_value("FEISHU_ALLOW_ALL_USERS", "false") - save_env_value("FEISHU_ALLOWED_USERS", "") - print_warning(" Direct messages disabled.") # ── Group policy ── print() diff --git a/tests/gateway/test_feishu_onboard.py b/tests/gateway/test_feishu_onboard.py index cb998fa5a..1ba1a64aa 100644 --- a/tests/gateway/test_feishu_onboard.py +++ b/tests/gateway/test_feishu_onboard.py @@ -248,6 +248,7 @@ class TestRenderQr: class TestProbeBot: """Tests for bot connectivity verification.""" + @patch("gateway.platforms.feishu.FEISHU_AVAILABLE", True) def test_probe_returns_bot_info_on_success(self): from gateway.platforms.feishu import probe_bot @@ -259,6 +260,7 @@ class TestProbeBot: assert result["bot_name"] == "TestBot" assert result["bot_open_id"] == "ou_bot123" + @patch("gateway.platforms.feishu.FEISHU_AVAILABLE", True) def test_probe_returns_none_on_failure(self): from gateway.platforms.feishu import probe_bot diff --git a/tests/gateway/test_setup_feishu.py b/tests/gateway/test_setup_feishu.py index 0b977cde9..26165528e 100644 --- a/tests/gateway/test_setup_feishu.py +++ b/tests/gateway/test_setup_feishu.py @@ -181,11 +181,6 @@ class TestSetupFeishuDmPolicy: env = self._run_with_dm_choice(2, prompt_responses=["ou_owner", ""]) assert env["FEISHU_ALLOWED_USERS"] == "ou_owner" - def test_disabled_sets_feishu_allow_all_false(self): - env = self._run_with_dm_choice(3) - assert env["FEISHU_ALLOW_ALL_USERS"] == "false" - assert env["FEISHU_ALLOWED_USERS"] == "" - assert "GATEWAY_ALLOW_ALL_USERS" not in env # ---------------------------------------------------------------------------