Skip to content

fix(feishu): send card JSON message params as cards#100883

Merged
vincentkoc merged 5 commits into
mainfrom
clownfish/gitcrawl-21-autonomous-drip-20260706
Jul 6, 2026
Merged

fix(feishu): send card JSON message params as cards#100883
vincentkoc merged 5 commits into
mainfrom
clownfish/gitcrawl-21-autonomous-drip-20260706

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Jul 6, 2026

Copy link
Copy Markdown
Member

Fixes #53486.

What Problem This Solves

Feishu message(action=send) and thread replies rendered valid native interactive-card JSON from the plain message or text parameter as raw text. This also affected the real runtime path where messages.responsePrefix is applied before plugin dispatch.

Why This Change Was Made

Feishu now detects and sanitizes supported native card JSON locally, including v2 body.elements, legacy top-level elements, wrapped interactive cards, and valid legacy div text elements. Explicit structured presentation or interactive input remains authoritative over raw card JSON, including document-comment fallback rendering. Malformed JSON, invalid root legacy text shapes, ordinary JSON, and card-plus-media requests keep their existing fallback or rejection behavior.

This preserves contributor credit for @martingarramon from #77268 and reporter credit for @ZenoRewn. Blocked lineage PRs #93706 and #94262 were evidence only and were not used as executable sources.

User Impact

Feishu proactive sends can render valid card JSON as interactive cards again, including when a configured response prefix is present. Structured card content is no longer discarded or preceded by raw JSON text.

Evidence

  • 125 focused Feishu tests passed.
  • 28 message-action runner tests passed, including the real response-prefix plugin-dispatch path.
  • Final compatibility repair: 60 outbound tests and 69 channel tests passed.
  • Regression coverage includes v2 cards, valid legacy div + lark_md/plain_text, invalid root legacy text fallback, wrapped cards, structured-input precedence, malformed/ordinary JSON fallback, and card-plus-media rejection.
  • Extension import-boundary, targeted formatting, and git diff --check passed.
  • Rebased through the native fork-update path onto current main.
  • Fresh exact-head hosted CI is running on b9eb00afe45f747dca4420bcb2c93e4423bcd921.
  • Maintainer proof override: no live Feishu tenant was used; parser, outbound adapter, action handler, and runtime prefix behavior are covered directly by focused tests and hosted CI.

@openclaw-barnacle openclaw-barnacle Bot added channel: feishu Channel integration: feishu size: L maintainer Maintainer-authored PR labels Jul 6, 2026
@vincentkoc
vincentkoc marked this pull request as draft July 6, 2026 12:22
@vincentkoc vincentkoc self-assigned this Jul 6, 2026
@clawsweeper

clawsweeper Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge. Reviewed July 6, 2026, 8:57 AM ET / 12:57 UTC.

Summary
The branch adds a Feishu native-card JSON parser/sanitizer shared by send actions and outbound payload/text sends, plus regression tests for card JSON, structured-input precedence, media rejection, and response-prefix handling.

PR surface: Source +124, Tests +525. Total +649 across 7 files.

Reproducibility: yes. Current-main source shows plain Feishu card JSON reaches the text path, and the PR's remaining prefix gap is source-reproducible because the runner applies channel/account prefixes while the new Feishu helper only strips the global prefix.

Review metrics: 1 noteworthy metric.

  • Prefix Cascade Coverage: 1 global level handled; 2 documented override levels missing. The PR strips messages.responsePrefix but not the channel/account overrides the runner can prepend before Feishu dispatch.

Stored data model
Persistent data-model change detected: serialized state: extensions/feishu/src/channel.test.ts, serialized state: extensions/feishu/src/outbound.test.ts, serialized state: src/infra/outbound/message-action-runner.plugin-dispatch.test.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #53486
Summary: This PR is the current open candidate fix for the canonical Feishu plain-message card JSON regression; prior direct parser PRs are closed unmerged.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🦐 gold shrimp
Proof: 🌊 off-meta tidepool
Patch quality: 🦐 gold shrimp
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:

  • [P2] Fix prefix stripping for channel/account responsePrefix overrides and add focused regression tests.

Risk before merge

  • [P1] Merging as-is would still deliver Feishu card JSON as raw text whenever the runner applies a channel-level or account-level responsePrefix override.
  • [P2] The change deliberately converts card-shaped JSON strings from text to native cards, so the prefix and fallback boundaries need to be exact before this message-delivery behavior ships.

Maintainer options:

  1. Align Prefix Stripping Before Merge (recommended)
    Resolve or pass the same global/channel/account responsePrefix that the message-action runner applied, then add focused Feishu card JSON tests for override prefixes.
  2. Accept Global-Only Prefix Support
    Maintainers could intentionally land the global-prefix repair now and leave channel/account-prefixed card JSON as a known follow-up gap.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Align Feishu native-card JSON response-prefix stripping with the documented messages/channel/account responsePrefix cascade used by the message-action runner, without importing core internals into the plugin; add focused regression tests for channels.feishu.responsePrefix and channels.feishu.accounts.<id>.responsePrefix card JSON sends.

Next step before merge

  • [P2] A narrow mechanical repair can make the Feishu prefix stripping match the runner and add targeted coverage.

Security
Cleared: No concrete security or supply-chain regression was found; the diff stays within Feishu parser/sanitizer code and tests without dependency, workflow, secret, or install-surface changes.

Review findings

  • [P2] Match the response-prefix cascade — extensions/feishu/src/channel.ts:596-610
Review details

Best possible solution:

Keep the Feishu-local parser, but strip the same responsePrefix cascade that the runner applies and cover global, channel, and account prefixes before merging.

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

Yes. Current-main source shows plain Feishu card JSON reaches the text path, and the PR's remaining prefix gap is source-reproducible because the runner applies channel/account prefixes while the new Feishu helper only strips the global prefix.

Is this the best way to solve the issue?

No, not yet. A Feishu-plugin-local parser is the maintainable layer, but it must match the runner's documented prefix cascade before this is the best fix.

Full review comments:

  • [P2] Match the response-prefix cascade — extensions/feishu/src/channel.ts:596-610
    The runner prefixes message(action=send) with resolveResponsePrefix(cfg, agentId, { channel, accountId }), which includes documented channels.<channel>.responsePrefix and account overrides. This helper only reads ctx.cfg.messages?.responsePrefix, so a Feishu channel/account prefix leaves [prefix] {card-json} unstripped and the new parser falls back to raw text. Please match the same cascade or pass the resolved prefix, and cover channel/account prefix regressions.
    Confidence: 0.9

Overall correctness: patch is incorrect
Overall confidence: 0.89

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 5cd71db85ec4.

Label changes

Label changes:

  • add P2: This is a bounded Feishu channel bugfix with a concrete remaining message-delivery gap, not a core outage.
  • add merge-risk: 🚨 message-delivery: The PR changes whether Feishu message text is delivered as raw text or a native card, and one documented prefixed path remains wrong.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: This is a maintainer-authored PR with an explicit proof override, so the external contributor real-behavior proof gate does not apply.

Label justifications:

  • P2: This is a bounded Feishu channel bugfix with a concrete remaining message-delivery gap, not a core outage.
  • merge-risk: 🚨 message-delivery: The PR changes whether Feishu message text is delivered as raw text or a native card, and one documented prefixed path remains wrong.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: This is a maintainer-authored PR with an explicit proof override, so the external contributor real-behavior proof gate does not apply.
Evidence reviewed

PR surface:

Source +124, Tests +525. Total +649 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 4 313 189 +124
Tests 3 531 6 +525
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 844 195 +649

Acceptance criteria:

  • [P1] pnpm test extensions/feishu/src/channel.test.ts extensions/feishu/src/outbound.test.ts src/infra/outbound/message-action-runner.plugin-dispatch.test.ts.
  • [P1] pnpm check:changed -- extensions/feishu/src/channel.ts extensions/feishu/src/native-card.ts extensions/feishu/src/channel.test.ts extensions/feishu/src/outbound.test.ts src/infra/outbound/message-action-runner.plugin-dispatch.test.ts.

What I checked:

Likely related people:

  • vincentkoc: Authored the adjacent Feishu native interactive-card payload support and the regression-window message-tool/Feishu media change; also owns this maintainer PR branch. (role: recent area contributor; confidence: high; commits: 2161b46032e0, 29ad211e7647; files: extensions/feishu/src/channel.ts, extensions/feishu/src/outbound.ts, extensions/feishu/src/send.ts)
  • ZengWen-DT: Authored the current message-tool responsePrefix application that the PR must match when stripping prefixed card JSON. (role: adjacent behavior introducer; confidence: medium; commits: 2af2eb2dfb17; files: src/infra/outbound/message-action-runner.ts)
  • steipete: Recent history shows repeated maintenance on Feishu channel runtime and shared outbound/message-action surfaces that this PR crosses. (role: recent adjacent contributor; confidence: medium; commits: d05e4a4bc6f2, 4c4e8a213f1a, 1507a9701b83; files: extensions/feishu/src/channel.ts, extensions/feishu/src/outbound.ts, src/infra/outbound/message-action-runner.ts)
  • m1heng: The Feishu package and manifest describe the plugin as community maintained by this handle, making them relevant for Feishu-specific compatibility expectations. (role: documented plugin contact; confidence: medium; files: extensions/feishu/package.json, extensions/feishu/openclaw.plugin.json)
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.

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. labels Jul 6, 2026
@vincentkoc
vincentkoc marked this pull request as ready for review July 6, 2026 13:05
@openclaw-barnacle openclaw-barnacle Bot added app: android App: android app: web-ui App: web-ui gateway Gateway runtime extensions: diagnostics-otel Extension: diagnostics-otel cli CLI command changes scripts Repository scripts agents Agent runtime and tooling extensions: qa-lab extensions: opencode-go extensions: xai labels Jul 6, 2026
@vincentkoc
vincentkoc merged commit 25a7708 into main Jul 6, 2026
189 of 214 checks passed
@vincentkoc
vincentkoc deleted the clownfish/gitcrawl-21-autonomous-drip-20260706 branch July 6, 2026 13:22
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 7, 2026
* fix(feishu): send plain card JSON as interactive cards

Co-authored-by: martingarramon <[email protected]>

* fix(clownfish): address review for gitcrawl-21-autonomous-drip-20260706 (1)

Co-authored-by: martingarramon <[email protected]>

* fix(feishu): preserve native card compatibility

Reported-by: @ZenoRewn
Co-authored-by: martingarramon <[email protected]>

* fix(feishu): fix native card fallback precedence

* fix(feishu): fix native card fallback precedence

---------

Co-authored-by: openclaw-clownfish[bot] <280122609+openclaw-clownfish[bot]@users.noreply.github.com>
Co-authored-by: martingarramon <[email protected]>
giodl73-repo pushed a commit to giodl73-repo/openclaw that referenced this pull request Jul 8, 2026
* fix(feishu): send plain card JSON as interactive cards

Co-authored-by: martingarramon <[email protected]>

* fix(clownfish): address review for gitcrawl-21-autonomous-drip-20260706 (1)

Co-authored-by: martingarramon <[email protected]>

* fix(feishu): preserve native card compatibility

Reported-by: @ZenoRewn
Co-authored-by: martingarramon <[email protected]>

* fix(feishu): fix native card fallback precedence

* fix(feishu): fix native card fallback precedence

---------

Co-authored-by: openclaw-clownfish[bot] <280122609+openclaw-clownfish[bot]@users.noreply.github.com>
Co-authored-by: martingarramon <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: android App: android app: web-ui App: web-ui channel: feishu Channel integration: feishu cli CLI command changes extensions: diagnostics-otel Extension: diagnostics-otel extensions: opencode-go extensions: qa-lab extensions: xai gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts size: XL status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Feishu: message(action=send) renders card JSON as plain text instead of interactive card (regression)

1 participant