Skip to content

fix(feishu): DM replies fail with error 230101 - #109637

Merged
steipete merged 2 commits into
openclaw:mainfrom
goutamadwant:fix-feishu-dm-replies
Jul 29, 2026
Merged

steipete merged 2 commits into
openclaw:mainfrom
goutamadwant:fix-feishu-dm-replies

Conversation

@goutamadwant

@goutamadwant goutamadwant commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

Closes #109409

What Problem This Solves

Feishu can reject a bot reply sent to a direct-message sender's open_id with
HTTP 400 and provider error 230101, even though delivering the same reply to the
existing inbound direct-message conversation succeeds. The agent completes its
response but the user sees nothing.

Why This Change Was Made

Route the reply dispatcher for a real inbound oc_ conversation to that
conversation's chat_id. Preserve the sender's open_id for authorization,
session identity, ACP routing, the persisted last route, and proactive messages.
Synthetic menu and card-action events without a real conversation retain their
original sender-target fallback. Update both the normal and active-broadcast
dispatcher paths without replacing current-main broadcast settlement.

This follows Feishu's send-message API
and the official Node SDK inbound-event example,
which responds to im.message.receive_v1 using its message.chat_id and
receive_id_type: "chat_id".

User Impact

Feishu users receive direct-message text, cards, media, and streaming replies
through the established conversation. Group replies, thread reply metadata,
synthetic events, proactive messages, sender-scoped session history, and
multi-account token isolation keep their existing behavior.

Evidence

Exact contributor head: bf8fcc63582c9172397532deebd613563d01125a.

Original contributor commit
0be0f0dbb84d0e6c2e56a078e249fc9c0915ecb1 is the refresh merge's first
parent. The current-main integration is its second parent; the original fork
branch was fast-forwarded without rewriting or force-pushing contributor
history.

Remote provider: Blacksmith Testbox tbx_01kypp3xxcmdhd2dr5vfkssq6d.

pnpm test \
  extensions/feishu/src/dm-delivery-loopback.test.ts \
  extensions/feishu/src/bot.test.ts \
  extensions/feishu/src/bot.broadcast.test.ts \
  extensions/feishu/src/reply-dispatcher.test.ts \
  extensions/feishu/src/send.test.ts \
  extensions/feishu/src/send.reply-fallback.test.ts \
  extensions/feishu/src/send-target.test.ts \
  extensions/feishu/src/media.test.ts \
  extensions/feishu/src/streaming-card.test.ts

Test Files  9 passed (9)
Tests       342 passed (342)
exitCode    0

The committed HTTP regression executes production sendMessageFeishu,
sendCardFeishu, sendMediaFeishu, resolveFeishuSendTarget,
createFeishuClient, the installed @larksuiteoapi/[email protected], and its
real Axios transport against a real local HTTP server. It verifies:

  • Actual HTTP tenant-token exchange for two independent Feishu accounts.
  • Account-correct Authorization: Bearer on every message and upload.
  • Actual HTTP 400 with provider code 230101 on the old user-open-ID target.
  • Actual authenticated chat_id text, interactive-card, and uploaded-image
    delivery.
  • Unchanged group targeting and threaded-reply endpoint and metadata.
  • Independent secondary-account authentication and routing.
  • Preserved proactive open-ID delivery and unrelated 230027 error propagation.

The contributor's original bot regression separately proves that an actual
inbound direct-message conversation selects chat:oc_dm while persisted route
identity remains user:ou_sender_1; synthetic p2p: events retain their
sender-scoped target. Current-main broadcast regression coverage also passes.

Fresh gpt-5.6-sol extra-high-effort structured review returned no actionable
findings (patch is correct, confidence 0.93). Targeted formatting and
git diff --check passed. The same remote Testbox independently completed the
entire pnpm check:changed extension-production and extension-test typecheck,
lint, formatting, dependency, plugin-boundary, and storage/import-cycle guards
with authoritative exitCode: 0. Exact-head GitHub CI run
30443791840
completed successfully.

Real behavior proof

  • Behavior: a Feishu DM reply can fail with actual provider error 230101 when
    targeted at open_id; its existing chat_id is deliverable.
  • Environment: genuine production plugin send paths, official Lark SDK, real
    Axios requests, a real authenticated local HTTP provider, and remote Linux
    Testbox.
  • Before: the test receives actual HTTP 400 / JSON code: 230101 from the
    sender-open-ID request.
  • After: actual Bearer-authenticated conversation text, card, and uploaded image
    requests return HTTP 200; group, thread, account, proactive, and error controls
    pass.
  • Limitation: no private live Feishu tenant credentials were available. The
    local provider is real HTTP and official SDK transport, not a claim of a live
    third-party tenant.

Disclosure: AI was used to understand the codebase and review the fix.

@openclaw-barnacle openclaw-barnacle Bot added channel: feishu Channel integration: feishu size: XS labels Jul 17, 2026
@goutamadwant
goutamadwant force-pushed the fix-feishu-dm-replies branch from 79a7416 to 0e0cc16 Compare July 17, 2026 04:30
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. labels Jul 17, 2026
@clawsweeper

clawsweeper Bot commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 17, 2026, 7:01 PM ET / 23:01 UTC.

Summary
The PR routes replies to inbound Feishu direct messages through the real conversation chat_id while preserving sender-scoped identity, session routing, and the synthetic-event fallback.

PR surface: Source +3, Tests +33. Total +36 across 2 files.

Reproducibility: no. high-confidence live after-fix reproduction is available in this review. The source path and focused regression clearly reproduce the incorrect dispatcher target, while the linked report supplies credible live before-fix API evidence.

Review metrics: none identified.

Stored data model
Persistent data-model change detected: serialized state: extensions/feishu/src/bot.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge readiness
Overall: 🦪 silver shellfish
Proof: 🦪 silver shellfish
Patch quality: 🐚 platinum hermit
Result: blocked until real behavior proof from a real setup is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P1] Add a redacted after-fix Feishu DM delivery transcript, terminal output, or runtime log from the current head.
  • Update the PR body with the evidence; if review does not restart automatically, ask a maintainer to comment @clawsweeper re-review.

Proof guidance:

  • [P1] Needs real behavior proof before merge: The PR has credible live before-fix tenant evidence and focused after-fix tests, but no redacted successful after-fix Feishu delivery from a real tenant; add a live transcript, runtime log, or terminal output from this head and redact private details before posting. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Risk before merge

  • [P1] Changing the dispatcher target from a user open_id to a conversation chat_id affects every DM reply surface; focused mocks cover routing selection, but only a live Feishu tenant can confirm that the remote API accepts text, card, media, and streaming replies after this change.

Maintainer options:

  1. Prove the live DM delivery path (recommended)
    Before merging, add redacted after-fix evidence from a Feishu tenant showing an inbound DM response succeeds through the oc_ conversation target.
  2. Accept the integration uncertainty
    A maintainer may merge based on the reporter's before-fix API comparison and targeted regression tests, accepting that remote Feishu delivery was not verified after the patch.

Next step before merge

  • [P1] The remaining merge blocker is real Feishu tenant evidence, which cannot be produced safely by an automated repair worker without credentials and an external integration setup.

Security
Cleared: The two-file patch changes only Feishu reply-target selection and unit coverage; it adds no dependencies, workflow changes, secrets handling, permissions, downloads, or supply-chain execution paths.

Review details

Best possible solution:

Obtain a redacted after-fix Feishu DM transcript, terminal output, or runtime log from this exact head that shows successful delivery through the inbound oc_ conversation, then refresh review against the current base.

Do we have a high-confidence way to reproduce the issue?

No high-confidence live after-fix reproduction is available in this review. The source path and focused regression clearly reproduce the incorrect dispatcher target, while the linked report supplies credible live before-fix API evidence.

Is this the best way to solve the issue?

Yes, conditionally: targeting the inbound real Feishu conversation is the narrowest repair because it leaves sender identity, policy, sessions, proactive sends, and synthetic-event handling unchanged; live API proof is still needed to confirm the Feishu contract.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 781913025b6f.

Label changes

Label changes:

  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🦪 silver shellfish, so this older rating label is no longer current.

Label justifications:

  • P1: The PR addresses a current channel workflow where a completed agent response can fail to reach a Feishu direct-message user.
  • merge-risk: 🚨 message-delivery: The patch intentionally changes the remote Feishu recipient target for inbound direct-message replies, so a contract mismatch could suppress or misdeliver replies.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR has credible live before-fix tenant evidence and focused after-fix tests, but no redacted successful after-fix Feishu delivery from a real tenant; add a live transcript, runtime log, or terminal output from this head and redact private details before posting. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed

PR surface:

Source +3, Tests +33. Total +36 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 5 2 +3
Tests 1 33 0 +33
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 38 2 +36

What I checked:

  • PR behavior and focused regression: The branch changes both Feishu reply-dispatcher construction sites to use feishuReplyTarget, selecting chat:<chatId> only for real oc_ conversations; the added test asserts chat:oc_dm for real DM replies and keeps user:ou_sender_1 for synthetic p2p: events. (extensions/feishu/src/bot.ts:790, 0be0f0dbb84d)
  • Issue-to-PR relationship: The PR explicitly closes the reported Feishu failure and the linked report documents a live API A/B result: delivery through open_id failed with error 230101 while the same message delivered through the inbound chat_id. (0be0f0dbb84d)
  • Available validation: The PR body reports the focused Feishu bot, send, and reply-dispatcher suite passing with 210 tests after the target change; GitHub checks in the supplied context are also successful. These support the implementation but do not demonstrate post-fix remote Feishu delivery. (extensions/feishu/src/bot.test.ts:730, 0be0f0dbb84d)
  • Review continuity: The current head matches the latest completed ClawSweeper review head, which already found no code-level defects and requested real Feishu after-fix evidence. No new code was supplied for this cycle to change that conclusion. (0be0f0dbb84d)

Likely related people:

  • m1heng: The supplied PR timeline shows direct participation around the Feishu review discussion, making this the strongest available routing signal without a readable local history pass. (role: discussion participant; confidence: low; files: extensions/feishu/src/bot.ts)
  • goutamadwant: Authored the focused Feishu reply-target change and its regression coverage; include for concrete follow-up on proof, not as a claim of current-main ownership. (role: current patch author; confidence: high; commits: 0be0f0dbb84d; files: extensions/feishu/src/bot.ts, extensions/feishu/src/bot.test.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
Review history (9 earlier review cycles; latest 8 shown)
  • reviewed 2026-07-17T07:49:52.661Z sha 349e5b5c7a4be7866aa80ed57cfb06a4b56e58cc :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-17T07:59:59.081Z sha f67c2d17fe56e10ebb861eabd534e1aeece65094 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-17T08:09:26.938Z sha 3a2c67cb9ea8f6b8a423a19ff4abedae56dbd7ff :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-17T15:00:49.580Z sha cd89cfe1052c6eafd5bad648bd644e9f7a2bfe67 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-17T15:43:54.587Z sha cd89cfe1052c6eafd5bad648bd644e9f7a2bfe67 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-17T20:08:10.968Z sha 22a26e48d2bbed3b9c3b9a178f60b7fc3b49786d :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-17T20:37:13.235Z sha 38c456a164b7e0d1ca0e7a29bd22804f96e15ba7 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-17T22:20:32.587Z sha 0be0f0d :: needs real behavior proof before merge. :: none

@goutamadwant
goutamadwant force-pushed the fix-feishu-dm-replies branch 5 times, most recently from cd89cfe to 22a26e4 Compare July 17, 2026 20:04
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jul 17, 2026
@goutamadwant
goutamadwant force-pushed the fix-feishu-dm-replies branch from 22a26e4 to 38c456a Compare July 17, 2026 20:33
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Jul 17, 2026
@goutamadwant
goutamadwant force-pushed the fix-feishu-dm-replies branch 2 times, most recently from 8d2429c to 3430a5e Compare July 17, 2026 22:15
@goutamadwant
goutamadwant force-pushed the fix-feishu-dm-replies branch from 3430a5e to 0be0f0d Compare July 17, 2026 22:17
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Jul 17, 2026
@amcccyu

amcccyu commented Jul 20, 2026

Copy link
Copy Markdown

✅ Real-environment verification

Test environment: Windows 11 · OpenClaw 2026.7.1 · Feishu tenant (Chinese domain)

Before the fix:
Sending a direct message to the bot resulted in error 230101 (Sending messages to users is temporarily unavailable) because the reply was dispatched with receive_id_type=open_id.

After applying the patch:
The three-line change from this PR was applied to the installed plugin:

  1. Added feishuReplyTarget that uses chat:${ctx.chatId} when chatId starts with oc_
  2. Replaced both sendTarget: feishuTo with sendTarget: feishuReplyTarget in createFeishuReplyDispatcher calls

Result: DM replies are now delivered successfully through the existing conversation chat_id. The bot responds to direct messages without error 230101.

Files patched:

@openclaw/feishu/dist/monitor.account-Dr7do33p.js
- const feishuReplyTarget = ctx.chatId.startsWith("oc_") ? `chat:${ctx.chatId}` : feishuTo;
- sendTarget: feishuReplyTarget (x2)

Verdict: This fix works correctly in a real Feishu environment. DM replies no longer fail with 230101 when dispatched through the conversation chat_id.

@amcccyu

amcccyu commented Jul 23, 2026

Copy link
Copy Markdown

@clawsweeper re-review

Real-environment proof has been added in the comment above. Successful DM reply delivery verified on a live Feishu tenant after applying this patch.

@steipete
steipete merged commit b11ed18 into openclaw:main Jul 29, 2026
101 of 103 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

vincentkoc added a commit to yetval/openclaw that referenced this pull request Jul 29, 2026
* origin/main: (224 commits)
  fix(memory): preserve Windows session ownership (openclaw#115851)
  fix(compaction): drop context-engine fallback on codex ownership skip (openclaw#114155) (openclaw#115666)
  fix(msteams): ignore blank certificate settings (openclaw#109112)
  fix(usage): guard malformed DeepSeek payloads (openclaw#110785)
  docs(agents): reword imported review rules in repo voice
  docs(agents): add context-budget, tool-description, cache-invalidation, and review-premise rules
  docs(agents): mock-gateway proof satisfies gate without discouraging live proof
  docs(agents): add vitest in-flight edit rule and mock-gateway proof recipe
  docs(agents): restructure root AGENTS.md around product doctrine and deduped policy
  fix(codex): keep completed answers over audit gaps (openclaw#115849)
  test(cli): isolate unknown-command process validation (openclaw#115848)
  fix(memory-host-sdk): resolve stable execPath for worker fork to survive Homebrew Node upgrades (openclaw#99318)
  feat(ui): add composer capability menu (openclaw#115800)
  fix(synology-chat): stop fabricating send message ids (openclaw#110770)
  fix(feishu): reply to direct messages by chat id (openclaw#109637)
  fix(acp): attach error listener to spawned ACP agent process (openclaw#109529)
  fix(sessions): deliver agent announcements to direct message sessions (openclaw#115811)
  fix(nextcloud-talk): reject reactions for disabled or unconfigured accounts (openclaw#112675)
  refactor(ui): move Agent Defaults entry from the sidebar into the Agents page (openclaw#115836)
  feat(gateway): push session PR indicators to subscribed clients (openclaw#115643)
  ...

# Conflicts:
#	src/agents/apply-patch.ts
#	src/agents/sandbox/fs-bridge-mutation-helper.ts
pull Bot pushed a commit to yann0001/openclaw that referenced this pull request Jul 29, 2026
* origin/main:
  docs(agents): reword imported review rules in repo voice
  docs(agents): add context-budget, tool-description, cache-invalidation, and review-premise rules
  docs(agents): mock-gateway proof satisfies gate without discouraging live proof
  docs(agents): add vitest in-flight edit rule and mock-gateway proof recipe
  docs(agents): restructure root AGENTS.md around product doctrine and deduped policy
  fix(codex): keep completed answers over audit gaps (openclaw#115849)
  test(cli): isolate unknown-command process validation (openclaw#115848)
  fix(memory-host-sdk): resolve stable execPath for worker fork to survive Homebrew Node upgrades (openclaw#99318)
  feat(ui): add composer capability menu (openclaw#115800)
  fix(synology-chat): stop fabricating send message ids (openclaw#110770)
  fix(feishu): reply to direct messages by chat id (openclaw#109637)
  fix(acp): attach error listener to spawned ACP agent process (openclaw#109529)
  fix(sessions): deliver agent announcements to direct message sessions (openclaw#115811)
  fix(nextcloud-talk): reject reactions for disabled or unconfigured accounts (openclaw#112675)
  refactor(ui): move Agent Defaults entry from the sidebar into the Agents page (openclaw#115836)
  feat(gateway): push session PR indicators to subscribed clients (openclaw#115643)
  fix(setup): make Gemini recovery actionable (openclaw#115835)
  fix(terminal-core): prevent String.replace $ pattern injection in display-string (openclaw#111398)
  refactor(channels): share ingress retention defaults (openclaw#115824)
  fix(nostr): profile imports vary on timestamp ties (openclaw#111798)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 30, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 30, 2026
* origin/main:
  docs(agents): reword imported review rules in repo voice
  docs(agents): add context-budget, tool-description, cache-invalidation, and review-premise rules
  docs(agents): mock-gateway proof satisfies gate without discouraging live proof
  docs(agents): add vitest in-flight edit rule and mock-gateway proof recipe
  docs(agents): restructure root AGENTS.md around product doctrine and deduped policy
  fix(codex): keep completed answers over audit gaps (openclaw#115849)
  test(cli): isolate unknown-command process validation (openclaw#115848)
  fix(memory-host-sdk): resolve stable execPath for worker fork to survive Homebrew Node upgrades (openclaw#99318)
  feat(ui): add composer capability menu (openclaw#115800)
  fix(synology-chat): stop fabricating send message ids (openclaw#110770)
  fix(feishu): reply to direct messages by chat id (openclaw#109637)
  fix(acp): attach error listener to spawned ACP agent process (openclaw#109529)
  fix(sessions): deliver agent announcements to direct message sessions (openclaw#115811)
  fix(nextcloud-talk): reject reactions for disabled or unconfigured accounts (openclaw#112675)
  refactor(ui): move Agent Defaults entry from the sidebar into the Agents page (openclaw#115836)
  feat(gateway): push session PR indicators to subscribed clients (openclaw#115643)
  fix(setup): make Gemini recovery actionable (openclaw#115835)
  fix(terminal-core): prevent String.replace $ pattern injection in display-string (openclaw#111398)
  refactor(channels): share ingress retention defaults (openclaw#115824)
  fix(nostr): profile imports vary on timestamp ties (openclaw#111798)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: feishu Channel integration: feishu merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: M status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

@openclaw/feishu plugin cannot send DM replies — error 230101

3 participants