feat(feishu): split DM/group display names with members-only DM lookup#38378
feat(feishu): split DM/group display names with members-only DM lookup#38378futuremind2026 wants to merge 6 commits intoopenclaw:mainfrom
Conversation
Greptile SummaryThis PR refactors Feishu display-name resolution by splitting DM and group paths into independent code flows, adding Key finding:
The caching logic, display-name builders, config schema additions, and test coverage are otherwise well-structured. Confidence Score: 3/5
Last reviewed commit: 43a01f4 |
| if (isDirect && (feishuCfg?.resolveDmDisplayNames ?? true)) { | ||
| const directName = await resolveFeishuDirectNameFromChatMember({ | ||
| account, | ||
| chatId: ctx.chatId, | ||
| senderOpenId: ctx.senderOpenId, | ||
| log, | ||
| }); | ||
| if (directName) { | ||
| ctx = { ...ctx, senderName: directName }; | ||
| } | ||
| } |
There was a problem hiding this comment.
ctx.senderOpenId may contain a user_id, causing silent no-match and wasted API call
ctx.senderOpenId is set to senderFallbackId (from parseFeishuMessageEvent line 938), which falls back to user_id when open_id is unavailable:
const senderFallbackId = senderOpenId || senderUserId || "";However, resolveFeishuDirectNameFromChatMember always calls the Feishu API with member_id_type: "open_id" (line 284), so all returned member_id values are in open_id format. The find() comparison at line 301 then tries to match those open_id values against a possibly-user_id-valued normalizedSenderOpenId — the match will always fail silently, making a wasted API call before returning undefined.
Guard the call with a confirmed open_id to avoid the needless API request:
const senderOpenId = event.sender.sender_id.open_id?.trim();
if (isDirect && senderOpenId && (feishuCfg?.resolveDmDisplayNames ?? true)) {
const directName = await resolveFeishuDirectNameFromChatMember({
account,
chatId: ctx.chatId,
senderOpenId,
log,
});
if (directName) {
ctx = { ...ctx, senderName: directName };
}
}Prompt To Fix With AI
This is a comment left during a code review.
Path: extensions/feishu/src/bot.ts
Line: 1078-1088
Comment:
`ctx.senderOpenId` may contain a `user_id`, causing silent no-match and wasted API call
`ctx.senderOpenId` is set to `senderFallbackId` (from `parseFeishuMessageEvent` line 938), which falls back to `user_id` when `open_id` is unavailable:
```ts
const senderFallbackId = senderOpenId || senderUserId || "";
```
However, `resolveFeishuDirectNameFromChatMember` always calls the Feishu API with `member_id_type: "open_id"` (line 284), so all returned `member_id` values are in `open_id` format. The `find()` comparison at line 301 then tries to match those `open_id` values against a possibly-`user_id`-valued `normalizedSenderOpenId` — the match will always fail silently, making a wasted API call before returning `undefined`.
Guard the call with a confirmed `open_id` to avoid the needless API request:
```ts
const senderOpenId = event.sender.sender_id.open_id?.trim();
if (isDirect && senderOpenId && (feishuCfg?.resolveDmDisplayNames ?? true)) {
const directName = await resolveFeishuDirectNameFromChatMember({
account,
chatId: ctx.chatId,
senderOpenId,
log,
});
if (directName) {
ctx = { ...ctx, senderName: directName };
}
}
```
How can I resolve this? If you propose a fix, please make it concise.There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 43a01f49cd
ℹ️ 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".
| const getChatMembers = client?.im?.chat?.members?.get; | ||
| if (typeof getChatMembers !== "function") { | ||
| return undefined; |
There was a problem hiding this comment.
Call the chat members endpoint exposed by the SDK
The new DM display-name path reads client?.im?.chat?.members?.get and returns early when that function is missing, but elsewhere in this Feishu extension the same SDK client is accessed as client.im.chatMembers.get (extensions/feishu/src/chat.ts). With the current SDK accessor shape, this makes resolveDmDisplayNames effectively a no-op in production and DM sender labels fall back to raw IDs.
Useful? React with 👍 / 👎.
| params: { | ||
| member_id_type: "open_id", | ||
| page_size: 50, |
There was a problem hiding this comment.
Derive member_id_type from the sender identifier
This lookup hardcodes member_id_type: "open_id" even when the event only provides user_id (the parser explicitly falls back to user_id when open_id is absent). In those DM events, member entries are returned in a different ID namespace, so entry.member_id === normalizedSenderOpenId never matches and display names always degrade to the raw ID.
Useful? React with 👍 / 👎.
|
Superseded by #38958, which carries the same Feishu DM/group display-name line with updated SDK-compatible DM member lookup ( with compatibility fallback), refreshed validation, and current branch/process conventions. Closing this to keep review focus on the latest patch set. |
|
Closing as superseded by #38958. The new PR keeps the same Feishu DM/group display-name direction, updates DM member lookup to SDK-compatible chatMembers path with compatibility fallback, and carries refreshed validation under the new branch/process conventions. |
Summary
resolveDmDisplayNames,resolveGroupNames) while preservingresolveSenderNamessemantics for sender-name resolution.im.chat.members.getmembers-only path and removed DM dependence oncontact.user.get.extensions/feishu/src/{bot.ts,bot.test.ts,channel.ts,config-schema.ts,config-schema.test.ts,types.ts}).Behavior
im.chat.members.get) with improved fallback/response handling.peer/parentPeer) are unchanged.Risk
resolveDmDisplayNamesrather than implicitly byresolveSenderNames.user_id(noopen_id), display name may fall back to ID when member matching is not possible.resolveDmDisplayNames: falseresolveGroupNames: false43a01f49cd,ea3a8163f7,edac6cd35a,1351950d81,b87d0b37fc.Validation
pnpm exec vitest run extensions/feishu/src/bot.test.ts extensions/feishu/src/config-schema.test.ts✅ (73 passed)pnpm exec vitest run extensions/feishu/src/*.test.tsextensions/feishu/src/targets.test.ts > treats explicit channel targets as chat_id(expectedchat_id, gotuser_id).pnpm build✅Notes for Reviewers
extensions/feishu/src/bot.tsextensions/feishu/src/bot.test.tsextensions/feishu/src/config-schema.tsextensions/feishu/src/config-schema.test.tsextensions/feishu/src/channel.tsextensions/feishu/src/types.tstargets.test.tsbaseline failure.