Skip to content

fix(feishu): respect region setting for WebSocket endpoint URL#1082

Open
octo-patch wants to merge 1 commit intoRightNow-AI:mainfrom
octo-patch:fix/issue-1081-lark-websocket-region
Open

fix(feishu): respect region setting for WebSocket endpoint URL#1082
octo-patch wants to merge 1 commit intoRightNow-AI:mainfrom
octo-patch:fix/issue-1081-lark-websocket-region

Conversation

@octo-patch
Copy link
Copy Markdown

Fixes #1081

Problem

When a user configures the Feishu/Lark channel with mode = "websocket" and region = "lark" (international), the WebSocket connection fails with:

ERROR openfang_channels::feishu: Feishu WebSocket error: Feishu WebSocket endpoint error:
WARN  openfang_channels::feishu: Feishu WebSocket reconnecting in 1s

This happens because of two bugs:

  1. FEISHU_WS_ENDPOINT_URL was hardcoded to https://open.feishu.cn/callback/ws/endpoint. Lark international apps register on open.larksuite.com, so their credentials are rejected by the Chinese endpoint.

  2. FeishuAdapter::new_websocket() always set region = FeishuRegion::Cn, completely ignoring the region field parsed from config.toml in channel_bridge.rs.

Solution

  • Renamed FEISHU_WS_ENDPOINT_URL to FEISHU_WS_ENDPOINT_PATH (stores just the path suffix /callback/ws/endpoint).
  • In FeishuAdapterClone::get_websocket_endpoint(), compute the full URL using self.region.domain() so Lark international users hit open.larksuite.com and Feishu CN users hit open.feishu.cn.
  • Added FeishuAdapter::new_websocket_with_region(app_id, app_secret, region) constructor.
  • Updated channel_bridge.rs to call new_websocket_with_region and pass the parsed region, so the user's region config field is now respected in WebSocket mode.

Testing

The existing unit tests pass. The fix was verified by code inspection: the FeishuAdapterClone already had a region field that was correctly cloned from the parent adapter — it was just never used in get_websocket_endpoint and never set correctly for WebSocket mode.

When using Lark international (open.larksuite.com) with WebSocket mode,
the adapter was hardcoding the Chinese Feishu endpoint URL and also
ignoring the configured region entirely when constructing the adapter.

Two bugs fixed:
1. FEISHU_WS_ENDPOINT_URL was hardcoded to open.feishu.cn — international
   Lark apps could not authenticate because their credentials are only
   valid on open.larksuite.com. Changed to FEISHU_WS_ENDPOINT_PATH and
   compute the full URL using self.region.domain() at call time.
2. new_websocket() in FeishuAdapter always set region = FeishuRegion::Cn.
   Added new_websocket_with_region() that accepts an explicit region, and
   updated the call site in channel_bridge.rs to pass the parsed region.

Fixes RightNow-AI#1081
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Lark websocket error

1 participant