Skip to content

fix(feishu): suppress NO_REPLY silent token before Feishu API calls - #56167

Closed
Talegqz wants to merge 1 commit into
openclaw:mainfrom
Talegqz:fix/feishu-suppress-no-reply-token
Closed

Talegqz wants to merge 1 commit into
openclaw:mainfrom
Talegqz:fix/feishu-suppress-no-reply-token

Conversation

@Talegqz

@Talegqz Talegqz commented Mar 28, 2026

Copy link
Copy Markdown

Summary

  • Add defense-in-depth NO_REPLY silent-token guard to feishuOutbound.sendText and feishuOutbound.sendMedia, matching the existing guard in the Slack plugin (extensions/slack/src/send.ts).
  • Heartbeat/cron push messages without reply context can bypass the upstream normalizeReplyPayload pipeline, leaking the internal NO_REPLY token as visible text to end users.
  • The sendText path now suppresses pure NO_REPLY messages before any Feishu API call; the sendMedia path strips NO_REPLY text captions while still delivering media attachments.

Changes

  • extensions/feishu/src/outbound.ts: Import isSilentReplyText from openclaw/plugin-sdk/reply-runtime and add guards in both sendText and sendMedia handlers.
  • extensions/feishu/src/outbound.test.ts: Add 4 test cases covering NO_REPLY suppression (exact match, whitespace-padded, substantive text passthrough, media-with-NO_REPLY-caption).

Test Plan

  • pnpm test -- extensions/feishu/src/outbound.test.ts — all 18 tests pass (14 existing + 4 new).

Closes #56117

@openclaw-barnacle openclaw-barnacle Bot added channel: feishu Channel integration: feishu size: S labels Mar 28, 2026
@greptile-apps

greptile-apps Bot commented Mar 28, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds defense-in-depth guards in extensions/feishu/src/outbound.ts to suppress the internal NO_REPLY silent token before Feishu API calls — mirroring the existing guard in the Slack plugin. The sendText guard is correct and well-tested. However, the sendMedia guard only covers the conditional text-send branch (when mediaUrl is present); the fallback branch at the end of sendMedia (lines 204–211), which fires when no mediaUrl is provided, passes the raw text value directly to sendOutboundText without checking isSilentReplyText, leaving the token leak open on that path.

Key changes:

  • sendText: early-return on isSilentReplyText(trimmedText) before any Feishu API call — correct.
  • sendMedia: guard added only to the first conditional text-send; the No media URL, just return text result fallback is unguarded.
  • 4 new test cases added covering sendText suppression and sendMedia with a mediaUrl; the sendMedia-without-mediaUrl edge case is not tested.

Confidence Score: 4/5

Safe to merge after addressing the unguarded sendMedia fallback path that can still leak NO_REPLY to end users.

The sendText guard is complete and correct. The sendMedia guard covers the primary use-case (mediaUrl present) but misses the no-mediaUrl fallback branch, leaving the original leak vector partially open. This is a present defect on the changed code path that should be fixed before merging.

extensions/feishu/src/outbound.ts — the sendMedia fallback block (lines 204–211) needs a NO_REPLY guard matching the one added for sendText.

Important Files Changed

Filename Overview
extensions/feishu/src/outbound.ts Adds NO_REPLY guard to sendText (correct) and the conditional text-send inside sendMedia (correct), but the fallback path in sendMedia that fires when no mediaUrl is present is unguarded and still leaks the token.
extensions/feishu/src/outbound.test.ts Adds 4 well-structured test cases covering the sendText and sendMedia (with mediaUrl) guard paths; missing a test for the sendMedia-without-mediaUrl edge case that exposes the leak.

Comments Outside Diff (1)

  1. extensions/feishu/src/outbound.ts, line 204-211 (link)

    P1 NO_REPLY token leaks through the sendMedia fallback path

    When sendMedia is called with text = "NO_REPLY" and no mediaUrl, the guard at line 169 correctly skips the text send, but execution falls through to this fallback block which calls sendOutboundText directly with the unguarded text ?? "" — which is "NO_REPLY". The token is never suppressed on this path.

    Example triggering flow:

    1. sendMedia({ text: "NO_REPLY", mediaUrl: undefined, ... })
    2. Guard at L169: condition is false (correctly suppressed) → skip
    3. if (mediaUrl) block at L180: skipped (no URL)
    4. L205: sendOutboundText({ text: "NO_REPLY", ... }) → token leaks to user

    This code path isn't covered by the four new test cases (all test the mediaUrl-present branch). A guard is needed here before the fallback call:

          // No media URL, just return text result
          const textToSend = text ?? "";
          if (isSilentReplyText(textToSend.trim())) {
            return { messageId: "suppressed", chatId: "" };
          }
          return await sendOutboundText({
            cfg,
            to,
            text: textToSend,
            accountId: accountId ?? undefined,
            replyToMessageId,
          });
    Prompt To Fix With AI
    This is a comment left during a code review.
    Path: extensions/feishu/src/outbound.ts
    Line: 204-211
    
    Comment:
    **NO_REPLY token leaks through the `sendMedia` fallback path**
    
    When `sendMedia` is called with `text = "NO_REPLY"` and no `mediaUrl`, the guard at line 169 correctly skips the text send, but execution falls through to this fallback block which calls `sendOutboundText` directly with the unguarded `text ?? ""` — which is `"NO_REPLY"`. The token is never suppressed on this path.
    
    Example triggering flow:
    1. `sendMedia({ text: "NO_REPLY", mediaUrl: undefined, ... })`
    2. Guard at L169: condition is `false` (correctly suppressed) → skip
    3. `if (mediaUrl)` block at L180: skipped (no URL)
    4. L205: `sendOutboundText({ text: "NO_REPLY", ... })` → token leaks to user
    
    This code path isn't covered by the four new test cases (all test the `mediaUrl`-present branch). A guard is needed here before the fallback call:
    
    ```typescript
          // No media URL, just return text result
          const textToSend = text ?? "";
          if (isSilentReplyText(textToSend.trim())) {
            return { messageId: "suppressed", chatId: "" };
          }
          return await sendOutboundText({
            cfg,
            to,
            text: textToSend,
            accountId: accountId ?? undefined,
            replyToMessageId,
          });
    ```
    
    How can I resolve this? If you propose a fix, please make it concise.
Prompt To Fix All With AI
This is a comment left during a code review.
Path: extensions/feishu/src/outbound.ts
Line: 204-211

Comment:
**NO_REPLY token leaks through the `sendMedia` fallback path**

When `sendMedia` is called with `text = "NO_REPLY"` and no `mediaUrl`, the guard at line 169 correctly skips the text send, but execution falls through to this fallback block which calls `sendOutboundText` directly with the unguarded `text ?? ""` — which is `"NO_REPLY"`. The token is never suppressed on this path.

Example triggering flow:
1. `sendMedia({ text: "NO_REPLY", mediaUrl: undefined, ... })`
2. Guard at L169: condition is `false` (correctly suppressed) → skip
3. `if (mediaUrl)` block at L180: skipped (no URL)
4. L205: `sendOutboundText({ text: "NO_REPLY", ... })` → token leaks to user

This code path isn't covered by the four new test cases (all test the `mediaUrl`-present branch). A guard is needed here before the fallback call:

```typescript
      // No media URL, just return text result
      const textToSend = text ?? "";
      if (isSilentReplyText(textToSend.trim())) {
        return { messageId: "suppressed", chatId: "" };
      }
      return await sendOutboundText({
        cfg,
        to,
        text: textToSend,
        accountId: accountId ?? undefined,
        replyToMessageId,
      });
```

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

Reviews (1): Last reviewed commit: "fix(feishu): suppress NO_REPLY silent to..." | Re-trigger Greptile

Heartbeat and cron push messages without reply context can bypass the
upstream normalize pipeline, leaking the internal NO_REPLY silent token
to end users as visible text.

Add defense-in-depth guards in feishuOutbound.sendText and sendMedia
(matching the existing Slack guard) that suppress NO_REPLY before any
Feishu API call.

Closes openclaw#56117
@Talegqz
Talegqz force-pushed the fix/feishu-suppress-no-reply-token branch from 2d9d0ce to 112211c Compare March 28, 2026 04:21
@EronFan

EronFan commented Mar 28, 2026

Copy link
Copy Markdown
Contributor

This directly fixes #56117 — Feishu push messages leaking internal NO_REPLY token to end users, which we have tracked as a high-priority issue. The fix follows the same defense-in-depth pattern already used in the Slack plugin, and adds proper test coverage (4 new test cases). LGTM, requesting maintainer review.

@clawsweeper

clawsweeper Bot commented Apr 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

Summary
The PR imports isSilentReplyText into Feishu outbound handling and adds tests intended to suppress exact NO_REPLY text while preserving substantive text and media sends.

Reproducibility: yes. at source level. On current main, feishuOutbound.sendMedia({ text: "NO_REPLY", mediaUrl: undefined }) reaches the no-media fallback that calls sendOutboundText({ text: text ?? "" }), so the literal token can be sent.

Next step before merge
A repair lane can safely finish this PR because the remaining work is a narrow Feishu outbound guard, regression-test, and changelog update with a clear source-level reproduction.

Security
Cleared: Cleared: the diff only touches Feishu outbound runtime code and tests, with no workflow, dependency, lockfile, package-script, generated-artifact, publishing, or secrets-handling changes.

Review findings

  • [P2] Guard all sendMedia text exits — extensions/feishu/src/outbound.ts:165-166
  • [P3] Add the changelog entry — extensions/feishu/src/outbound.ts:95-102
Review details

Best possible solution:

Land one Feishu-owned fix on current main that filters exact silent tokens before every Feishu outbound text API boundary, preserves media and substantive text, adds focused regression tests, and records the user-facing fix in the changelog.

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

Yes, at source level. On current main, feishuOutbound.sendMedia({ text: "NO_REPLY", mediaUrl: undefined }) reaches the no-media fallback that calls sendOutboundText({ text: text ?? "" }), so the literal token can be sent.

Is this the best way to solve the issue?

No. The PR chooses the right SDK helper and plugin boundary, but it is incomplete until all Feishu text exits, including the no-media fallback, are guarded and covered by tests plus a changelog entry.

Full review comments:

  • [P2] Guard all sendMedia text exits — extensions/feishu/src/outbound.ts:165-166
    The new sendMedia condition only skips the leading caption send. If the call has text: "NO_REPLY" and no mediaUrl, execution still reaches the fallback that sends text ?? "", so the token remains visible; centralize the silent-token check before every Feishu text API boundary and cover the no-media case.
    Confidence: 0.93
  • [P3] Add the changelog entry — extensions/feishu/src/outbound.ts:95-102
    This is a user-visible Feishu fix, but the PR only changes Feishu source and tests. Add a single-line CHANGELOG.md entry under the active fixes section before merge.
    Confidence: 0.82

Overall correctness: patch is incorrect
Overall confidence: 0.91

Acceptance criteria:

  • pnpm test extensions/feishu/src/outbound.test.ts
  • pnpm exec oxfmt --check --threads=1 extensions/feishu/src/outbound.ts extensions/feishu/src/outbound.test.ts CHANGELOG.md
  • pnpm check:changed

What I checked:

Likely related people:

  • vincentkoc: Authored the latest Feishu-specific outbound change in the local current-main history, touching extensions/feishu/src/outbound.ts, outbound.test.ts, and media.ts; the PR timeline also shows Vincent assigned to this PR. (role: recent Feishu outbound maintainer; confidence: high; commits: 14312ff5704f; files: extensions/feishu/src/outbound.ts, extensions/feishu/src/outbound.test.ts, extensions/feishu/src/media.ts)
  • Val Alexander: The local path history shows a recent main commit touching the Feishu outbound source and test files, though the commit subject is a broader plugin/package-maintenance change rather than Feishu-specific behavior. (role: recent adjacent maintainer; confidence: medium; commits: 85c000de1efa; files: extensions/feishu/src/outbound.ts, extensions/feishu/src/outbound.test.ts)

Remaining risk / open question:

  • The PR branch is based on an older Feishu outbound shape and should be rebased against current main's newer voice/comment/media paths before final validation.

Codex review notes: model gpt-5.5, reasoning high; reviewed against 39bc94e4ddf5.

@vincentkoc vincentkoc self-assigned this May 3, 2026
@openclaw-barnacle

Copy link
Copy Markdown

This assigned pull request has been automatically marked as stale after being open for 27 days.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label May 4, 2026
@openclaw-barnacle

Copy link
Copy Markdown

Closing due to inactivity.
If you believe this PR should be revived, post in #clawtributors on Discord to talk to a maintainer.
That channel is the escape hatch for high-quality PRs that get auto-closed.

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 stale Marked as stale due to inactivity

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Feishu push messages display literal 'NO_REPLY' text when no reply context exists

3 participants