From 7db95926b08626ab688400562977d2996078ae36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=87=AF=E5=BC=BA?= Date: Mon, 30 Mar 2026 11:42:07 +0800 Subject: [PATCH] feat(feishu): add configurable domain for Lark international support (#1535) The lark-oapi SDK defaults to open.feishu.cn (China), but apps on the international Lark platform (open.larksuite.com) fail to connect with error 1000040351 'Incorrect domain name'. Changes: - Add 'domain' config option to feishu channel (default: open.feishu.cn) - Pass domain to both API client and WebSocket client - Update config.example.yaml and all README files --- README.md | 2 ++ README_fr.md | 2 ++ README_ja.md | 2 ++ README_ru.md | 2 ++ README_zh.md | 2 ++ backend/app/channels/feishu.py | 9 ++++++--- config.example.yaml | 2 ++ 7 files changed, 18 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index efb72a656..3e6682c6f 100644 --- a/README.md +++ b/README.md @@ -323,6 +323,8 @@ channels: enabled: true app_id: $FEISHU_APP_ID app_secret: $FEISHU_APP_SECRET + # domain: https://open.feishu.cn # China (default) + # domain: https://open.larksuite.com # International slack: enabled: true diff --git a/README_fr.md b/README_fr.md index 53ea3e4dd..e7684a5f8 100644 --- a/README_fr.md +++ b/README_fr.md @@ -314,6 +314,8 @@ channels: enabled: true app_id: $FEISHU_APP_ID app_secret: $FEISHU_APP_SECRET + # domain: https://open.feishu.cn # China (default) + # domain: https://open.larksuite.com # International slack: enabled: true diff --git a/README_ja.md b/README_ja.md index b653f9ee7..3e0ff4c85 100644 --- a/README_ja.md +++ b/README_ja.md @@ -267,6 +267,8 @@ channels: enabled: true app_id: $FEISHU_APP_ID app_secret: $FEISHU_APP_SECRET + # domain: https://open.feishu.cn # China (default) + # domain: https://open.larksuite.com # International slack: enabled: true diff --git a/README_ru.md b/README_ru.md index 0b62bb35d..6ee30ebc6 100644 --- a/README_ru.md +++ b/README_ru.md @@ -265,6 +265,8 @@ channels: enabled: true app_id: $FEISHU_APP_ID app_secret: $FEISHU_APP_SECRET + # domain: https://open.feishu.cn # China (default) + # domain: https://open.larksuite.com # International slack: enabled: true diff --git a/README_zh.md b/README_zh.md index 6dece0a4f..3a838e72c 100644 --- a/README_zh.md +++ b/README_zh.md @@ -255,6 +255,8 @@ channels: enabled: true app_id: $FEISHU_APP_ID app_secret: $FEISHU_APP_SECRET + # domain: https://open.feishu.cn # 国内版(默认) + # domain: https://open.larksuite.com # 国际版 slack: enabled: true diff --git a/backend/app/channels/feishu.py b/backend/app/channels/feishu.py index c51e66019..2001a87de 100644 --- a/backend/app/channels/feishu.py +++ b/backend/app/channels/feishu.py @@ -92,12 +92,14 @@ class FeishuChannel(Channel): app_id = self.config.get("app_id", "") app_secret = self.config.get("app_secret", "") + domain = self.config.get("domain", "https://open.feishu.cn") if not app_id or not app_secret: logger.error("Feishu channel requires app_id and app_secret") return - self._api_client = lark.Client.builder().app_id(app_id).app_secret(app_secret).build() + self._api_client = lark.Client.builder().app_id(app_id).app_secret(app_secret).domain(domain).build() + logger.info("[Feishu] using domain: %s", domain) self._main_loop = asyncio.get_event_loop() self._running = True @@ -109,13 +111,13 @@ class FeishuChannel(Channel): # which conflicts with an already-running uvloop. self._thread = threading.Thread( target=self._run_ws, - args=(app_id, app_secret), + args=(app_id, app_secret, domain), daemon=True, ) self._thread.start() logger.info("Feishu channel started") - def _run_ws(self, app_id: str, app_secret: str) -> None: + def _run_ws(self, app_id: str, app_secret: str, domain: str) -> None: """Construct and run the lark WS client in a thread with a fresh event loop. The lark-oapi SDK captures a module-level event loop at import time @@ -145,6 +147,7 @@ class FeishuChannel(Channel): app_secret=app_secret, event_handler=event_handler, log_level=lark.LogLevel.INFO, + domain=domain, ) ws_client.start() except Exception: diff --git a/config.example.yaml b/config.example.yaml index 137a5af3d..ad82cdc7f 100644 --- a/config.example.yaml +++ b/config.example.yaml @@ -617,6 +617,8 @@ checkpointer: # enabled: false # app_id: $FEISHU_APP_ID # app_secret: $FEISHU_APP_SECRET +# # domain: https://open.feishu.cn # China (default) +# # domain: https://open.larksuite.com # International # # slack: # enabled: false