fix(feishu): respect region setting for WebSocket endpoint URL#1082
Open
octo-patch wants to merge 1 commit intoRightNow-AI:mainfrom
Open
fix(feishu): respect region setting for WebSocket endpoint URL#1082octo-patch wants to merge 1 commit intoRightNow-AI:mainfrom
octo-patch wants to merge 1 commit intoRightNow-AI:mainfrom
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1081
Problem
When a user configures the Feishu/Lark channel with
mode = "websocket"andregion = "lark"(international), the WebSocket connection fails with:This happens because of two bugs:
FEISHU_WS_ENDPOINT_URLwas hardcoded tohttps://open.feishu.cn/callback/ws/endpoint. Lark international apps register onopen.larksuite.com, so their credentials are rejected by the Chinese endpoint.FeishuAdapter::new_websocket()always setregion = FeishuRegion::Cn, completely ignoring theregionfield parsed fromconfig.tomlinchannel_bridge.rs.Solution
FEISHU_WS_ENDPOINT_URLtoFEISHU_WS_ENDPOINT_PATH(stores just the path suffix/callback/ws/endpoint).FeishuAdapterClone::get_websocket_endpoint(), compute the full URL usingself.region.domain()so Lark international users hitopen.larksuite.comand Feishu CN users hitopen.feishu.cn.FeishuAdapter::new_websocket_with_region(app_id, app_secret, region)constructor.channel_bridge.rsto callnew_websocket_with_regionand pass the parsed region, so the user'sregionconfig field is now respected in WebSocket mode.Testing
The existing unit tests pass. The fix was verified by code inspection: the
FeishuAdapterClonealready had aregionfield that was correctly cloned from the parent adapter — it was just never used inget_websocket_endpointand never set correctly for WebSocket mode.