fix(feishu): restore private chat pairing replies in Lark/Feishu#31403
fix(feishu): restore private chat pairing replies in Lark/Feishu#31403Takhoffman merged 2 commits intoopenclaw:mainfrom
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0cd9a780a0
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| await sendMessageFeishu({ | ||
| cfg, | ||
| to: `user:${ctx.senderOpenId}`, | ||
| to: `chat:${ctx.chatId}`, |
There was a problem hiding this comment.
Keep pairing reply target valid for synthetic p2p events
Using chat:${ctx.chatId} here breaks the reaction fallback path when Feishu omits chat_id: resolveReactionSyntheticEvent synthesizes chat_id as p2p:${senderId} (extensions/feishu/src/monitor.account.ts:95), so this code now sends to chat:p2p:..., which normalizes to an invalid receive id and causes sendMessageFeishu to fail in pairing mode. Before this change, the same path replied via user:${ctx.senderOpenId}, which remains valid for these synthetic DM events.
Useful? React with 👍 / 👎.
Greptile SummaryThis PR fixes a regression where Feishu/Lark private chat pairing replies failed for mobile users. After commit Key changes:
Confidence Score: 5/5
Last reviewed commit: 0cd9a78 |
0cd9a78 to
1ee4e24
Compare
|
PR #31403 - fix(feishu): restore private chat pairing replies in Lark/Feishu (#31403) Merged after verification.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1ee4e24f31
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| await sendMessageFeishu({ | ||
| cfg, | ||
| to: `user:${ctx.senderOpenId}`, | ||
| to: `chat:${ctx.chatId}`, |
There was a problem hiding this comment.
Avoid chat targeting for synthetic p2p fallback IDs
When pairing is required in DMs, this now always sends the challenge to chat:${ctx.chatId}; however, resolveReactionSyntheticEvent can synthesize chat_id as p2p:<sender> when Feishu omits chat_id (extensions/feishu/src/monitor.account.ts), so this path produces chat:p2p:..., which is normalized as a chat_id target and fails delivery. In that reaction fallback scenario, unauthorized users never receive the pairing reply, whereas the prior user:${ctx.senderOpenId} target remained valid for these synthetic DM events.
Useful? React with 👍 / 👎.
…nclaw#31403) thanks @stakeswky Verified: - pnpm test -- extensions/feishu/src/bot.test.ts - pnpm build Co-authored-by: stakeswky <64798754+stakeswky@users.noreply.github.com> Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
…nclaw#31403) thanks @stakeswky Verified: - pnpm test -- extensions/feishu/src/bot.test.ts - pnpm build Co-authored-by: stakeswky <64798754+stakeswky@users.noreply.github.com> Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
…nclaw#31403) thanks @stakeswky Verified: - pnpm test -- extensions/feishu/src/bot.test.ts - pnpm build Co-authored-by: stakeswky <64798754+stakeswky@users.noreply.github.com> Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
Summary
Fixes a regression where Feishu/Lark private chat (p2p) users could not receive pairing replies.
In p2p events, the sender identity may be
user_id(mobile delivery) while outbound message send targeting for DMs should use the conversationchat_id(or a valid open_id). After recent sender-id fallback changes, pairing reply routing useduser:${ctx.senderOpenId}and could becomeuser:<user_id>, which is not a validopen_idreceive target in this flow.This made DM onboarding/pairing appear broken while group @mention flows still worked.
Root Cause
In
handleFeishuMessage()unauthorized DM pairing path, the reply target was built from sender id:to: \user:${ctx.senderOpenId}``With the
open_id -> user_idfallback introduced for inbound sender identity, this path can now pass auser_idunder theuser:prefix, causing Feishu send failures and no DM response.Fix
to: \chat:${ctx.chatId}``This is stable for p2p regardless of whether inbound sender id is open_id or user_id.
Tests
Added/updated tests in
extensions/feishu/src/bot.test.ts:replies pairing challenge to DM chat_id instead of user:sender idchat:oc-dmRan:
pnpm vitest run --config vitest.extensions.config.ts extensions/feishu/src/bot.test.ts extensions/feishu/src/bot.checkBotMentioned.test.tsCloses #31351