Skip to content

feishu: fall back to user_id for inbound sender identity#26703

Merged
Takhoffman merged 2 commits intoopenclaw:mainfrom
NewdlDewdl:fix/issue-26642-feishu-mobile-dashboard
Feb 28, 2026
Merged

feishu: fall back to user_id for inbound sender identity#26703
Takhoffman merged 2 commits intoopenclaw:mainfrom
NewdlDewdl:fix/issue-26642-feishu-mobile-dashboard

Conversation

@NewdlDewdl
Copy link
Contributor

@NewdlDewdl NewdlDewdl commented Feb 25, 2026

Summary

  • Fix Feishu inbound sender identity handling when sender_id.open_id is missing (common on some mobile deliveries).
  • Fall back to sender_id.user_id so inbound messages keep a stable sender id for routing, metadata, and dashboard rendering.
  • Update sender-name lookup to detect id type (open_id/user_id/union_id) before calling Feishu contact APIs.
  • Add a regression test for parsing events that only include user_id.

Issue

Validation

  • pnpm build
  • pnpm check
  • pnpm test
  • Full quality gate: scripts/quality_gate.sh (build, format:check, tsgo, lint, test)

Risk

  • Low: change is scoped to Feishu inbound id normalization and sender lookup id-type selection.
  • Rollback: revert this PR commit.

AI-assisted disclosure

  • Assistance: AI-assisted
  • Testing depth: fully tested
  • Author confirms understanding of all code in this PR

Greptile Summary

Fixes Feishu inbound message handling when sender_id.open_id is missing by falling back to sender_id.user_id, which prevents message routing failures on some mobile deliveries.

  • Updated parseFeishuMessageEvent to use user_id as fallback for sender identity fields
  • Modified resolveFeishuSenderName to accept generic senderId and auto-detect ID type (open_id/user_id/union_id) via prefix matching
  • Added new resolveSenderLookupIdType function to determine correct Feishu API parameter based on ID prefix
  • Added regression test covering the user_id-only case

Critical finding:

  • Inconsistent fallback priority between senderId (prioritizes user_id) and senderOpenId (prioritizes open_id) in bot.ts:485-495 could cause routing/allowlist mismatches when both IDs are present

Confidence Score: 3/5

  • safe to merge with caution - one logical inconsistency needs verification
  • the PR correctly implements the user_id fallback for sender identity and adds proper test coverage, but has an inconsistent fallback priority between senderId and senderOpenId fields that could cause subtle routing bugs when both user_id and open_id are present
  • verify bot.ts:485-495 - check if different priorities for senderId vs senderOpenId is intentional or should use same fallback order

Last reviewed commit: 9eb398d

@openclaw-barnacle openclaw-barnacle bot added channel: feishu Channel integration: feishu size: S labels Feb 25, 2026
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Comment on lines +485 to +495
const senderOpenId = event.sender.sender_id.open_id?.trim();
const senderUserId = event.sender.sender_id.user_id?.trim();
const senderFallbackId = senderOpenId || senderUserId || "";

const ctx: FeishuMessageContext = {
chatId: event.message.chat_id,
messageId: event.message.message_id,
senderId: event.sender.sender_id.user_id || event.sender.sender_id.open_id || "",
senderOpenId: event.sender.sender_id.open_id || "",
senderId: senderUserId || senderOpenId || "",
// Keep the historical field name, but fall back to user_id when open_id is unavailable
// (common in some mobile app deliveries).
senderOpenId: senderFallbackId,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inconsistent fallback priority between senderId and senderOpenId

Lines 492 and 495 have opposite priority orders:

  • Line 492: senderId: senderUserId || senderOpenId || ""
  • Line 495: senderOpenId: senderFallbackId (where senderFallbackId = senderOpenId || senderUserId)

this means when only user_id is present:

  • senderId = user_id
  • senderOpenId = user_id

but when both are present:

  • senderId = user_id (prioritizes user_id)
  • senderOpenId = open_id (prioritizes open_id)

the comment on line 493-494 says senderOpenId falls back to user_id when open_id is unavailable, but the actual behavior prioritizes open_id when both exist. since the field is named senderOpenId and the historical behavior was to use open_id, this is probably correct, but the inconsistency with senderId could cause subtle bugs in routing/allowlist matching where both fields are checked

Suggested change
const senderOpenId = event.sender.sender_id.open_id?.trim();
const senderUserId = event.sender.sender_id.user_id?.trim();
const senderFallbackId = senderOpenId || senderUserId || "";
const ctx: FeishuMessageContext = {
chatId: event.message.chat_id,
messageId: event.message.message_id,
senderId: event.sender.sender_id.user_id || event.sender.sender_id.open_id || "",
senderOpenId: event.sender.sender_id.open_id || "",
senderId: senderUserId || senderOpenId || "",
// Keep the historical field name, but fall back to user_id when open_id is unavailable
// (common in some mobile app deliveries).
senderOpenId: senderFallbackId,
const ctx: FeishuMessageContext = {
chatId: event.message.chat_id,
messageId: event.message.message_id,
senderId: senderFallbackId,
// Keep the historical field name, but fall back to user_id when open_id is unavailable
// (common in some mobile app deliveries).
senderOpenId: senderFallbackId,
Prompt To Fix With AI
This is a comment left during a code review.
Path: extensions/feishu/src/bot.ts
Line: 485-495

Comment:
inconsistent fallback priority between `senderId` and `senderOpenId`

Lines 492 and 495 have opposite priority orders:
- Line 492: `senderId: senderUserId || senderOpenId || ""`
- Line 495: `senderOpenId: senderFallbackId` (where `senderFallbackId = senderOpenId || senderUserId`)

this means when only `user_id` is present:
- `senderId` = `user_id`- `senderOpenId` = `user_id` ✓

but when both are present:
- `senderId` = `user_id` (prioritizes user_id)
- `senderOpenId` = `open_id` (prioritizes open_id)

the comment on line 493-494 says `senderOpenId` falls back to `user_id` when `open_id` is unavailable, but the actual behavior prioritizes `open_id` when both exist. since the field is named `senderOpenId` and the historical behavior was to use `open_id`, this is probably correct, but the inconsistency with `senderId` could cause subtle bugs in routing/allowlist matching where both fields are checked

```suggestion
  const ctx: FeishuMessageContext = {
    chatId: event.message.chat_id,
    messageId: event.message.message_id,
    senderId: senderFallbackId,
    // Keep the historical field name, but fall back to user_id when open_id is unavailable
    // (common in some mobile app deliveries).
    senderOpenId: senderFallbackId,
```

How can I resolve this? If you propose a fix, please make it concise.

@Takhoffman Takhoffman force-pushed the fix/issue-26642-feishu-mobile-dashboard branch from 9eb398d to 5ed488d Compare February 28, 2026 04:59
@Takhoffman Takhoffman merged commit e0b1b48 into openclaw:main Feb 28, 2026
9 checks passed
@Takhoffman
Copy link
Contributor

PR #26703 - feishu: fall back to user_id for inbound sender identity (#26703)

Merged via squash.

  • Merge commit: e0b1b48
  • Verified: pnpm install --frozen-lockfile, pnpm build, pnpm check, pnpm test:macmini
  • Changes made:
    M CHANGELOG.md
  • Why these changes were made:
    Added the required changelog entry so the user-visible Feishu inbound sender-id fallback fix is documented for release notes.
  • Changelog: CHANGELOG.md updated=true required=true opt_out=false

Thanks @NewdlDewdl!

r4jiv007 pushed a commit to r4jiv007/openclaw that referenced this pull request Feb 28, 2026
) thanks @NewdlDewdl

Verified:
- pnpm install --frozen-lockfile
- pnpm build
- pnpm check
- pnpm test:macmini

Co-authored-by: NewdlDewdl <230946873+NewdlDewdl@users.noreply.github.com>
Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
mylukin pushed a commit to mylukin/openclaw that referenced this pull request Feb 28, 2026
) thanks @NewdlDewdl

Verified:
- pnpm install --frozen-lockfile
- pnpm build
- pnpm check
- pnpm test:macmini

Co-authored-by: NewdlDewdl <230946873+NewdlDewdl@users.noreply.github.com>
Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
wanjizheng pushed a commit to wanjizheng/openclaw that referenced this pull request Feb 28, 2026
) thanks @NewdlDewdl

Verified:
- pnpm install --frozen-lockfile
- pnpm build
- pnpm check
- pnpm test:macmini

Co-authored-by: NewdlDewdl <230946873+NewdlDewdl@users.noreply.github.com>
Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
wanjizheng pushed a commit to wanjizheng/openclaw that referenced this pull request Feb 28, 2026
) thanks @NewdlDewdl

Verified:
- pnpm install --frozen-lockfile
- pnpm build
- pnpm check
- pnpm test:macmini

Co-authored-by: NewdlDewdl <230946873+NewdlDewdl@users.noreply.github.com>
Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
(cherry picked from commit 4ae9cbe)
wanjizheng pushed a commit to wanjizheng/openclaw that referenced this pull request Feb 28, 2026
) thanks @NewdlDewdl

Verified:
- pnpm install --frozen-lockfile
- pnpm build
- pnpm check
- pnpm test:macmini

Co-authored-by: NewdlDewdl <230946873+NewdlDewdl@users.noreply.github.com>
Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
(cherry picked from commit 4ae9cbe)
wanjizheng pushed a commit to wanjizheng/openclaw that referenced this pull request Feb 28, 2026
) thanks @NewdlDewdl

Verified:
- pnpm install --frozen-lockfile
- pnpm build
- pnpm check
- pnpm test:macmini

Co-authored-by: NewdlDewdl <230946873+NewdlDewdl@users.noreply.github.com>
Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
(cherry picked from commit 4ae9cbe)
vincentkoc pushed a commit to Sid-Qin/openclaw that referenced this pull request Feb 28, 2026
) thanks @NewdlDewdl

Verified:
- pnpm install --frozen-lockfile
- pnpm build
- pnpm check
- pnpm test:macmini

Co-authored-by: NewdlDewdl <230946873+NewdlDewdl@users.noreply.github.com>
Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
vincentkoc pushed a commit to rylena/rylen-openclaw that referenced this pull request Feb 28, 2026
) thanks @NewdlDewdl

Verified:
- pnpm install --frozen-lockfile
- pnpm build
- pnpm check
- pnpm test:macmini

Co-authored-by: NewdlDewdl <230946873+NewdlDewdl@users.noreply.github.com>
Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
newtontech pushed a commit to newtontech/openclaw-fork that referenced this pull request Feb 28, 2026
) thanks @NewdlDewdl

Verified:
- pnpm install --frozen-lockfile
- pnpm build
- pnpm check
- pnpm test:macmini

Co-authored-by: NewdlDewdl <230946873+NewdlDewdl@users.noreply.github.com>
Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
wanjizheng pushed a commit to wanjizheng/openclaw that referenced this pull request Mar 1, 2026
) thanks @NewdlDewdl

Verified:
- pnpm install --frozen-lockfile
- pnpm build
- pnpm check
- pnpm test:macmini

Co-authored-by: NewdlDewdl <230946873+NewdlDewdl@users.noreply.github.com>
Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
wanjizheng pushed a commit to wanjizheng/openclaw that referenced this pull request Mar 1, 2026
) thanks @NewdlDewdl

Verified:
- pnpm install --frozen-lockfile
- pnpm build
- pnpm check
- pnpm test:macmini

Co-authored-by: NewdlDewdl <230946873+NewdlDewdl@users.noreply.github.com>
Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
hughdidit pushed a commit to hughdidit/DAISy-Agency that referenced this pull request Mar 1, 2026
) thanks @NewdlDewdl

Verified:
- pnpm install --frozen-lockfile
- pnpm build
- pnpm check
- pnpm test:macmini

Co-authored-by: NewdlDewdl <230946873+NewdlDewdl@users.noreply.github.com>
Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
(cherry picked from commit e0b1b48)

# Conflicts:
#	CHANGELOG.md
#	extensions/feishu/src/bot.ts
zooqueen added a commit to hanzoai/bot that referenced this pull request Mar 1, 2026
ansh pushed a commit to vibecode/openclaw that referenced this pull request Mar 2, 2026
) thanks @NewdlDewdl

Verified:
- pnpm install --frozen-lockfile
- pnpm build
- pnpm check
- pnpm test:macmini

Co-authored-by: NewdlDewdl <230946873+NewdlDewdl@users.noreply.github.com>
Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
steipete pushed a commit to Sid-Qin/openclaw that referenced this pull request Mar 2, 2026
) thanks @NewdlDewdl

Verified:
- pnpm install --frozen-lockfile
- pnpm build
- pnpm check
- pnpm test:macmini

Co-authored-by: NewdlDewdl <230946873+NewdlDewdl@users.noreply.github.com>
Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
safzanpirani pushed a commit to safzanpirani/clawdbot that referenced this pull request Mar 2, 2026
) thanks @NewdlDewdl

Verified:
- pnpm install --frozen-lockfile
- pnpm build
- pnpm check
- pnpm test:macmini

Co-authored-by: NewdlDewdl <230946873+NewdlDewdl@users.noreply.github.com>
Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
steipete pushed a commit to Sid-Qin/openclaw that referenced this pull request Mar 2, 2026
) thanks @NewdlDewdl

Verified:
- pnpm install --frozen-lockfile
- pnpm build
- pnpm check
- pnpm test:macmini

Co-authored-by: NewdlDewdl <230946873+NewdlDewdl@users.noreply.github.com>
Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
venjiang pushed a commit to venjiang/openclaw that referenced this pull request Mar 2, 2026
) thanks @NewdlDewdl

Verified:
- pnpm install --frozen-lockfile
- pnpm build
- pnpm check
- pnpm test:macmini

Co-authored-by: NewdlDewdl <230946873+NewdlDewdl@users.noreply.github.com>
Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
robertchang-ga pushed a commit to robertchang-ga/openclaw that referenced this pull request Mar 2, 2026
) thanks @NewdlDewdl

Verified:
- pnpm install --frozen-lockfile
- pnpm build
- pnpm check
- pnpm test:macmini

Co-authored-by: NewdlDewdl <230946873+NewdlDewdl@users.noreply.github.com>
Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
execute008 pushed a commit to execute008/openclaw that referenced this pull request Mar 2, 2026
) thanks @NewdlDewdl

Verified:
- pnpm install --frozen-lockfile
- pnpm build
- pnpm check
- pnpm test:macmini

Co-authored-by: NewdlDewdl <230946873+NewdlDewdl@users.noreply.github.com>
Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
hughdidit pushed a commit to hughdidit/DAISy-Agency that referenced this pull request Mar 3, 2026
) thanks @NewdlDewdl

Verified:
- pnpm install --frozen-lockfile
- pnpm build
- pnpm check
- pnpm test:macmini

Co-authored-by: NewdlDewdl <230946873+NewdlDewdl@users.noreply.github.com>
Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
(cherry picked from commit e0b1b48)

# Conflicts:
#	CHANGELOG.md
dorgonman pushed a commit to kanohorizonia/openclaw that referenced this pull request Mar 3, 2026
) thanks @NewdlDewdl

Verified:
- pnpm install --frozen-lockfile
- pnpm build
- pnpm check
- pnpm test:macmini

Co-authored-by: NewdlDewdl <230946873+NewdlDewdl@users.noreply.github.com>
Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
sachinkundu pushed a commit to sachinkundu/openclaw that referenced this pull request Mar 6, 2026
) thanks @NewdlDewdl

Verified:
- pnpm install --frozen-lockfile
- pnpm build
- pnpm check
- pnpm test:macmini

Co-authored-by: NewdlDewdl <230946873+NewdlDewdl@users.noreply.github.com>
Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
zooqueen added a commit to hanzoai/bot that referenced this pull request Mar 6, 2026
zooqueen pushed a commit to hanzoai/bot that referenced this pull request Mar 6, 2026
) thanks @NewdlDewdl

Verified:
- pnpm install --frozen-lockfile
- pnpm build
- pnpm check
- pnpm test:macmini

Co-authored-by: NewdlDewdl <230946873+NewdlDewdl@users.noreply.github.com>
Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
Mateljan1 pushed a commit to Mateljan1/openclaw that referenced this pull request Mar 7, 2026
) thanks @NewdlDewdl

Verified:
- pnpm install --frozen-lockfile
- pnpm build
- pnpm check
- pnpm test:macmini

Co-authored-by: NewdlDewdl <230946873+NewdlDewdl@users.noreply.github.com>
Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: feishu Channel integration: feishu size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Dashboard doesn't show messages sent from Feishu mobile app

2 participants