Skip to content

fix(feishu): avoid mention forwarding when bot open id is unavailable - #100891

Merged
steipete merged 2 commits into
openclaw:mainfrom
zhangguiping-xydt:fix/problem-feishu-missing-bot-open-id-mention
Jul 6, 2026
Merged

steipete merged 2 commits into
openclaw:mainfrom
zhangguiping-xydt:fix/problem-feishu-missing-bot-open-id-mention

Conversation

@zhangguiping-xydt

@zhangguiping-xydt zhangguiping-xydt commented Jul 6, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where Feishu direct-message mention forwarding could be triggered when the bot open id was unavailable. In that state, ordinary user mentions were treated as mention-forward targets even though OpenClaw could not reliably know whether the bot was addressed.

Why This Change Was Made

The Feishu mention-forward check now stops early when the bot open id is missing, so it only evaluates “bot plus other user” or direct-message mention forwarding when the bot identity is known. This keeps the change scoped to mention-forward detection and does not change Feishu message parsing, broadcast mention filtering, or outbound mention formatting.

User Impact

Feishu users should no longer see accidental mention-forward behavior during bot identity probe/configuration gaps. Normal mention forwarding remains unchanged when the bot open id is available.

Evidence

  • Signed Feishu webhook runtime proof, using the same monitor path as webhook mode: monitorSingleAccount(webhook) -> signed HTTP POST -> EventDispatcher -> handleFeishuMessage -> channel.inbound.run. Payload IDs below are synthetic/redacted local proof values.

    Feishu signed webhook runtime proof for mention-forward detection
    Surface: monitorSingleAccount(webhook) -> signed HTTP POST -> EventDispatcher -> handleFeishuMessage -> channel.inbound.run
    
    === missing botOpenId DM with Alice mention ===
    HTTP POST status: 200
    Dispatch count: 1
    Runtime logs:
      feishu[proof-missing-bot]: bot open_id resolved: unknown
      feishu[proof-missing-bot]: received message from ou_sender_1 in oc_dm_missing_bot (p2p)
      feishu[proof-missing-bot]: dispatching to agent (session=agent:main:feishu:direct:ou_sender_1)
      feishu[proof-missing-bot]: dispatch complete (queuedFinal=false, replies=0)
    Agent BodyForAgent mention-target line:
      <none>
    
    === known botOpenId group with bot + Alice mentions ===
    HTTP POST status: 200
    Dispatch count: 1
    Runtime logs:
      feishu[proof-known-bot]: bot open_id resolved: ou_bot_1
      feishu[proof-known-bot]: received message from ou_sender_1 in oc_proof_group (group)
      feishu[proof-known-bot]: detected @ forward request, targets: [Alice]
      feishu[proof-known-bot]: dispatching to agent (session=agent:main:feishu:group:oc_proof_group)
      feishu[proof-known-bot]: dispatch complete (queuedFinal=false, replies=0)
    Agent BodyForAgent mention-target line:
      [System: Feishu users mentioned in the incoming message, for context only: "Alice". Do not notify or mention these users solely because they are listed here.]
    
    RESULT: PASS
    
  • corepack [email protected] exec node scripts/run-vitest.mjs run extensions/feishu/src/bot.checkBotMentioned.test.ts

    [test] starting test/vitest/vitest.extension-feishu.config.ts
    The `envFile` option is deprecated, please use `envDir: false` instead.
    
     RUN  v4.1.9 [local path redacted]
    
    
     Test Files  1 passed (1)
          Tests  24 passed (24)
       Start at  20:43:09
       Duration  18.05s (transform 9.86s, setup 79ms, import 17.58s, tests 20ms, environment 0ms)
    
    [test] passed 1 Vitest shard in 29.56s
    
  • corepack [email protected] exec node scripts/run-vitest.mjs run extensions/feishu/src/monitor.message-handler.test.ts

    [test] starting test/vitest/vitest.extension-feishu.config.ts
    The `envFile` option is deprecated, please use `envDir: false` instead.
    
     RUN  v4.1.9 [local path redacted]
    
    
     Test Files  1 passed (1)
          Tests  2 passed (2)
       Start at  20:43:58
       Duration  789ms (transform 283ms, setup 71ms, import 373ms, tests 14ms, environment 0ms)
    
    [test] passed 1 Vitest shard in 12.00s
    

@openclaw-barnacle openclaw-barnacle Bot added channel: feishu Channel integration: feishu size: XS labels Jul 6, 2026
@clawsweeper

clawsweeper Bot commented Jul 6, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed July 6, 2026, 12:52 PM ET / 16:52 UTC.

Summary
This PR makes Feishu mention-forward detection require a known, trimmed bot open_id, adds parser regression coverage, and adds a CHANGELOG entry.

PR surface: Source +5, Tests +11, Docs +1. Total +17 across 4 files.

Reproducibility: yes. source-reproducible: current main treats a direct-message user mention as a mention-forward request when botOpenId is undefined, then attaches mentionTargets in parseFeishuMessageEvent. I did not run a live Feishu tenant reproduction.

Review metrics: 1 noteworthy metric.

  • Mention-forward identity guard: 1 fail-closed guard added. The diff changes behavior for Feishu messages handled while the bot open_id is missing, so maintainers should notice the compatibility choice before merge.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🦞 diamond lobster
Patch quality: 🐚 platinum hermit
Result: ready for maintainer review.

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

Rank-up moves:

  • Remove the PR-local CHANGELOG.md entry or get explicit release-owner acceptance for it.
  • [P1] Have a maintainer confirm the fail-closed bot-identity behavior before merge.

Risk before merge

  • [P1] Merging intentionally makes Feishu mention forwarding fail closed while bot identity is unavailable; existing installations in a probe or recovery gap will stop forwarding mentions instead of guessing.
  • [P1] The PR-local CHANGELOG entry conflicts with the repository's release-owned changelog policy and should be removed or explicitly accepted by release owners before merge.

Maintainer options:

  1. Accept the fail-closed upgrade behavior (recommended)
    Maintainers can accept that Feishu mention forwarding is disabled until bot identity is known, using the PR's signed-webhook proof as the channel evidence.
  2. Require a compatibility-preserving shape
    Maintainers can ask for a different implementation if legacy identity-gap forwarding must remain available during bot identity recovery.

Next step before merge

  • [P2] A maintainer should accept the compatibility behavior and decide whether to remove or explicitly keep the release-owned changelog edit before merge.

Maintainer decision needed

  • Question: Should Feishu mention forwarding intentionally fail closed whenever botOpenId is unavailable?
  • Rationale: The source fix is narrow and proof is sufficient, but it changes behavior during bot identity probe or recovery gaps, which the repository treats as compatibility-sensitive.
  • Likely owner: steipete — steipete is assigned and force-pushed the follow-up commit that shaped the final fail-closed guard.
  • Options:
    • Accept fail-closed identity guard (recommended): Merge after removing or explicitly accepting the release-owned CHANGELOG edit; this prevents accidental forwarding when OpenClaw cannot know whether the bot was addressed.
    • Preserve legacy identity-gap forwarding: Keep DM mention forwarding while bot identity is missing, accepting the current risk of forwarding mentions when the bot identity is unknown.

Security
Cleared: Cleared: the diff changes Feishu parser behavior, tests, and changelog text only; no dependencies, workflows, package scripts, permissions, credentials, or supply-chain surfaces are modified.

Review findings

  • [P3] Remove the release-owned changelog edit — CHANGELOG.md:24
Review details

Best possible solution:

Keep the Feishu-owned guard and regression coverage, remove the PR-local CHANGELOG entry, and merge only after maintainer acceptance of the fail-closed identity-gap behavior.

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

Yes, source-reproducible: current main treats a direct-message user mention as a mention-forward request when botOpenId is undefined, then attaches mentionTargets in parseFeishuMessageEvent. I did not run a live Feishu tenant reproduction.

Is this the best way to solve the issue?

Yes for the runtime change: guarding at the Feishu mention-forward boundary is the narrow owner-local fix, and the updated proof covers missing and known bot identity paths. The PR-local CHANGELOG edit is not part of the best fix and should be removed.

Full review comments:

  • [P3] Remove the release-owned changelog edit — CHANGELOG.md:24
    This PR now adds a CHANGELOG.md entry, but root AGENTS.md says normal PRs should keep release-note context in the PR body or squash message while release generation owns CHANGELOG.md. Please drop this line so the release-owned changelog is generated from merged PR context.
    Confidence: 0.89

Overall correctness: patch is correct
Overall confidence: 0.86

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 6b99fd9a94ce.

Label changes

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body now includes redacted signed-webhook runtime logs showing missing bot open_id suppresses mention targets and known bot open_id still detects the intended target.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (logs): The PR body now includes redacted signed-webhook runtime logs showing missing bot open_id suppresses mention targets and known bot open_id still detects the intended target.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: This is a normal-priority Feishu channel bug fix with limited blast radius and focused proof.
  • merge-risk: 🚨 compatibility: Merging can stop mention-forward dispatch for existing Feishu users during bot identity gaps, even though that fail-closed behavior appears intentional.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (logs): The PR body now includes redacted signed-webhook runtime logs showing missing bot open_id suppresses mention targets and known bot open_id still detects the intended target.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body now includes redacted signed-webhook runtime logs showing missing bot open_id suppresses mention targets and known bot open_id still detects the intended target.
Evidence reviewed

PR surface:

Source +5, Tests +11, Docs +1. Total +17 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 2 11 6 +5
Tests 1 11 0 +11
Docs 1 1 0 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 23 6 +17

What I checked:

  • Current main source-reproduces the identity-gap bug: On current main, isMentionForwardRequest returns true for a direct message when any user mention has an open_id different from botOpenId; when botOpenId is undefined, an ordinary user mention satisfies that predicate. (extensions/feishu/src/mention.ts:60, 6b99fd9a94ce)
  • Current main attaches mention targets from that predicate: parseFeishuMessageEvent calls isMentionForwardRequest(event, botOpenId) and then assigns extracted mentionTargets, which is the forwarding path this PR narrows. (extensions/feishu/src/bot.ts:321, 6b99fd9a94ce)
  • Bot identity can be unavailable at runtime: Feishu monitoring applies possibly missing bot identity, logs unknown, and starts background identity recovery when no bot open_id is available. (extensions/feishu/src/monitor.account.ts:478, 6b99fd9a94ce)
  • Sibling Feishu identity-dependent path already fails closed: Drive comment handling skips processing when botOpenId is unavailable, supporting the same fail-closed shape for identity-dependent mention behavior. (extensions/feishu/src/monitor.comment.ts:1255, 6b99fd9a94ce)
  • PR diff narrows mention-forward detection: The PR trims botOpenId, skips mention-forward checks when it is blank, and passes the normalized id to target extraction; it also table-tests undefined, empty, and whitespace bot ids. (extensions/feishu/src/mention.ts:62, 8ae0bf02f49b)
  • Updated real behavior proof is present: The PR body includes redacted signed-webhook runtime logs for the monitorSingleAccount webhook path showing no mention-target line when bot open_id is unknown and normal target detection when bot open_id is known. (8ae0bf02f49b)

Likely related people:

  • steipete: Live PR timeline shows steipete assigned this PR and force-pushed the follow-up commit; GitHub history also shows repeated recent Feishu bot, monitor, and helper changes. (role: recent broad Feishu contributor and current PR follow-up committer; confidence: high; commits: 8ae0bf02f49b, 58912f8fd842, d05e4a4bc6f2; files: extensions/feishu/src/bot.ts, extensions/feishu/src/mention.ts, extensions/feishu/src/monitor.message-handler.ts)
  • vincentkoc: GitHub history shows recent changes to Feishu mention helpers and types, including the @ALL bot-mention fix and mention type split that cover the same parser boundary. (role: recent area contributor; confidence: high; commits: b642ebece9b0, 2b96f53f9782, e46bcb834faa; files: extensions/feishu/src/mention.ts, extensions/feishu/src/bot.ts, extensions/feishu/src/reply-dispatcher.ts)
  • MonkeyLeeT: The merged automatic mention cascade fix changed how inbound Feishu mention targets are carried into outbound replies, which is adjacent to this PR's mention-target creation path. (role: adjacent behavior contributor; confidence: medium; commits: 43ea5c3e6fe8; files: extensions/feishu/src/bot.ts, extensions/feishu/src/reply-dispatcher.ts)
  • doodlewind: The Feishu community plugin import introduced the current bundled Feishu plugin files, including the bot, mention, send, and reply dispatcher surfaces involved here. (role: introduced bundled Feishu plugin surface; confidence: medium; commits: 2267d58afcc7; files: extensions/feishu/src/bot.ts, extensions/feishu/src/mention.ts, extensions/feishu/src/reply-dispatcher.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 (1 earlier review cycle)
  • reviewed 2026-07-06T13:25:22.082Z sha a921f7ea07326355945651a6b943d3287f8ab784 :: needs real behavior proof before merge. :: none

@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. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Jul 6, 2026
@zhangguiping-xydt

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 6, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@steipete steipete self-assigned this Jul 6, 2026
@steipete
steipete force-pushed the fix/problem-feishu-missing-bot-open-id-mention branch from d86a74d to 8ae0bf0 Compare July 6, 2026 16:43
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed 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. labels Jul 6, 2026
@steipete

steipete commented Jul 6, 2026 •

Copy link
Copy Markdown
Contributor

Maintainer repair is land-ready at exact head d843cc5b6ecbe92ffc68929f03b304bc5da5b573.

  • Best-fix review: mention forwarding now requires one normalized, known bot open ID. Missing, empty, and whitespace-only identity states fail closed without dropping the inbound message; known-identity DM and group behavior remains unchanged.
  • The release-owned CHANGELOG.md edit was removed, and the focused three-file patch was rebased onto current main.
  • The PR body contains signed-webhook runtime proof for both paths: unknown bot identity produces no mention-target metadata, while known bot identity still forwards the intended user target.
  • Sanitized AWS Crabbox cbx_98684aac5435, run run_2c8db28ea5ca: public networking, no Tailscale, no instance profile, no credential hydration; 39/39 focused parser, message-handler, and signed-request webhook tests passed.
  • git diff --check passed. Fresh GPT-5.5 autoreview reported no accepted or actionable findings.
  • Exact-head hosted CI passed: https://github.com/openclaw/openclaw/actions/runs/28810963700

Proof gap: no production Feishu tenant was mutated. The changed surface is deterministic inbound event classification, covered by the signed HTTP webhook path and focused runtime tests without credentials.

@steipete
steipete force-pushed the fix/problem-feishu-missing-bot-open-id-mention branch 2 times, most recently from 824aca3 to d7277c5 Compare July 6, 2026 17:28
@steipete
steipete force-pushed the fix/problem-feishu-missing-bot-open-id-mention branch from d7277c5 to d843cc5 Compare July 6, 2026 17:36
@steipete
steipete merged commit f805bb4 into openclaw:main Jul 6, 2026
100 of 143 checks passed
@steipete

steipete commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Merged via squash.

1 similar comment
@steipete

steipete commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 7, 2026
…openclaw#100891)

* fix(feishu): avoid forwarding mentions without bot open id

* fix(feishu): require bot identity for mention forwarding

---------

Co-authored-by: Peter Steinberger <[email protected]>
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: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants