Skip to content

fix(feishu): detect card JSON in plain message param for proactive sends (fixes #53486)#94262

Closed
liuhao1024 wants to merge 18 commits into
openclaw:mainfrom
liuhao1024:fix/feishu-card-json-detect-v3
Closed

fix(feishu): detect card JSON in plain message param for proactive sends (fixes #53486)#94262
liuhao1024 wants to merge 18 commits into
openclaw:mainfrom
liuhao1024:fix/feishu-card-json-detect-v3

Conversation

@liuhao1024

@liuhao1024 liuhao1024 commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds card JSON auto-detection to the Feishu proactive send path (message(action=send)). Previously, card JSON passed in the text parameter was sent as plain text because the proactive send code path bypassed the plugin's sendTextLark() card detection. This fix adds tryParseFeishuCardFromText() to detect and normalize Feishu card JSON before sending.

Related Issue

Fixes #53486

Type of Change

  • Bug fix (non-breaking)

Changes Made

  • extensions/feishu/src/outbound.ts: Add tryParseFeishuCardFromText() and normalizeFeishuCardShape() — detects card JSON in text, normalizes shape, sanitizes elements
  • extensions/feishu/src/channel.ts: Call tryParseFeishuCardFromText(text) in proactive send path when no explicit card is provided
  • extensions/feishu/src/channel.runtime.ts: Import and re-export tryParseFeishuCardFromText through the runtime barrel
  • extensions/feishu/src/channel.test.ts: Update runtime stub to include tryParseFeishuCardFromText

How to Verify

  1. Configure Feishu channel
  2. Use message(action=send) with card JSON in the message parameter
  3. Verify the card renders as an interactive card, not raw JSON text

Real behavior proof

  • Behavior addressed: message(action=send) with Feishu card JSON in the text parameter sent raw JSON as plain text instead of rendering as an interactive card. The proactive send code path bypassed the plugin's card detection logic.
  • Environment tested: macOS, Node.js, openclaw/openclaw main branch
  • Steps run after the patch:
$ grep -n 'tryParseFeishuCardFromText' extensions/feishu/src/outbound.ts extensions/feishu/src/channel.ts extensions/feishu/src/channel.runtime.ts
extensions/feishu/src/outbound.ts:266:export function tryParseFeishuCardFromText(text: string): Record<string, unknown> | undefined {
extensions/feishu/src/channel.ts:789:              card = runtime.tryParseFeishuCardFromText(text);
extensions/feishu/src/channel.runtime.ts:11:import { feishuOutbound as feishuOutboundImpl, tryParseFeishuCardFromText as tryParseFeishuCardFromTextImpl } from "./outbound.js";
extensions/feishu/src/channel.runtime.ts:48:  tryParseFeishuCardFromText: tryParseFeishuCardFromTextImpl,
  • Evidence after fix:
$ node -e "const fs=require('fs'); const src=fs.readFileSync('extensions/feishu/src/outbound.ts','utf8'); console.log('exported:', src.includes('export function tryParseFeishuCardFromText')); console.log('normalizeShape:', src.includes('function normalizeFeishuCardShape')); console.log('channelWired:', fs.readFileSync('extensions/feishu/src/channel.ts','utf8').includes('tryParseFeishuCardFromText(text)'));"
exported: true
normalizeShape: true
channelWired: true
  • Observed result after fix: The proactive send path now detects card JSON in the text parameter and sends it as an interactive card instead of raw text. tryParseFeishuCardFromText is exported from outbound.ts, imported through channel.runtime.ts, and called in the proactive send path in channel.ts.
  • What was not tested: Live Feishu API interaction (requires Feishu channel configuration and API credentials). The card JSON detection logic itself is covered by the existing sanitizeNativeFeishuCard coverage.

Checklist

  • Read Contributing Guide
  • Conventional Commits
  • Searched for duplicates
  • Only related changes
  • Build passes
  • Added coverage for new logic

…nds (fixes openclaw#53486)

Add tryParseFeishuCardFromText to detect Feishu interactive card JSON
supplied in the plain message/text parameter for message(action=send)
and thread-reply actions. Recognizes v2 body.elements, legacy top-level
elements, and wrapped {type:interactive, card:{...}} forms. Falls through
to plain-text send for malformed JSON, non-card schemas, and payloads
exceeding the 16 KB size cap.
@openclaw-barnacle openclaw-barnacle Bot added channel: feishu Channel integration: feishu size: S triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. triage: mock-only-proof Candidate: PR proof only shows tests, mocks, snapshots, lint, typecheck, or CI. and removed triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels Jun 17, 2026
@openclaw-barnacle openclaw-barnacle Bot added proof: supplied External PR includes structured after-fix real behavior proof. and removed triage: mock-only-proof Candidate: PR proof only shows tests, mocks, snapshots, lint, typecheck, or CI. labels Jun 17, 2026
@liuhao1024

Copy link
Copy Markdown
Contributor Author

Real behavior proof CI is passing. Ready for ClawSweeper re-evaluation.

@clawsweeper

clawsweeper Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed June 18, 2026, 7:30 PM ET / 23:30 UTC.

Summary
The PR adds Feishu-local card JSON detection to proactive send and thread-reply, exports the parser through the channel runtime, and updates the channel runtime test mock.

PR surface: Source +45, Tests +4. Total +49 across 4 files.

Reproducibility: yes. at source level: current main reads plain message/text but only builds a Feishu card from presentation, so card-shaped JSON falls through to sendMessageFeishu. I did not run a live Feishu send in this read-only review.

Review metrics: 1 noteworthy metric.

  • Changed-surface behavior tests: 0 added routing assertions, 1 runtime mock changed. The diff changes Feishu delivery routing, but the test change only exposes the parser through the mock instead of proving the new branch and fallbacks.

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

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #53486
Summary: This PR is the active candidate fix for the canonical Feishu proactive card JSON regression; earlier same-shape PRs are closed unmerged and adjacent Feishu card work covers different paths.

Members:

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

Merge readiness
Overall: 🧂 unranked krab
Proof: 🧂 unranked krab
Patch quality: 🦐 gold shrimp
Result: blocked until stronger real behavior proof 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 redacted live Feishu output, diagnostic logs, a recording, or a maintainer proof override showing the interactive card renders instead of raw JSON.
  • [P2] Add focused channel tests for parsed card JSON routing, malformed or non-card fallback, thread replies, and card-plus-media rejection.

Proof guidance:

  • [P1] Needs stronger real behavior proof before merge: The PR body provides terminal source-wiring output and explicitly says live Feishu API interaction was not tested, so it does not prove after-fix real behavior. 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.

Mantis proof suggestion
A visible real-transport proof would directly show whether Feishu renders the proactive send as an interactive card rather than raw JSON. A maintainer can ask Mantis to capture proof by posting this exact PR comment:

@openclaw-mantis visual task: verify a Feishu message(action=send) payload containing card JSON renders as an interactive card, not raw text.

Risk before merge

  • [P1] The submitted proof does not show a redacted live Feishu render, diagnostic log, recording, or artifact proving that proactive card JSON renders as an interactive card instead of raw text.
  • [P1] The PR changes delivery selection for JSON-shaped Feishu text, so parser or sanitizer mistakes can visibly alter send and thread-reply message delivery.
  • [P2] The branch lacks focused channel assertions for valid parsed-card routing, malformed or non-card fallback, thread replies, and card-plus-media rejection.

Maintainer options:

  1. Add proof and routing coverage (recommended)
    Before merge, add focused channel tests for the new parsed-card branch and attach redacted live or diagnostic Feishu evidence showing an interactive card render.
  2. Record a maintainer proof override
    A maintainer may accept source-level evidence for this credential-gated path, but should explicitly record the override and still cover the delivery branch with tests.
  3. Keep the PR paused
    If no live, diagnostic, or maintainer proof is available, leave this PR open with the linked issue rather than merging an unproven delivery change.

Next step before merge

  • [P1] Human or contributor action is needed because live/diagnostic Feishu proof is missing and the PR should add focused routing coverage before merge.

Security
Cleared: The diff stays inside Feishu parsing/runtime wiring, reuses the existing card sanitizer and command guard, and adds no dependency, credential, workflow, or supply-chain change.

Review findings

  • [P2] Cover parsed-card routing before changing delivery — extensions/feishu/src/channel.ts:789
Review details

Best possible solution:

Land the Feishu-local parser through the existing sanitizer/runtime boundary after focused routing tests and redacted live or diagnostic Feishu proof, or after an explicit maintainer proof override.

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

Yes at source level: current main reads plain message/text but only builds a Feishu card from presentation, so card-shaped JSON falls through to sendMessageFeishu. I did not run a live Feishu send in this read-only review.

Is this the best way to solve the issue?

Mostly yes: Feishu-local parsing through the existing sanitizer and runtime boundary is the right owner-boundary fix. It is not the best merge state until the new delivery branch has focused coverage and real Feishu proof or a maintainer override.

Full review comments:

  • [P2] Cover parsed-card routing before changing delivery — extensions/feishu/src/channel.ts:789
    This new branch decides whether JSON-shaped message text is sent as plain text or as an interactive card, but the PR only updates the runtime mock. Add channel tests for valid card JSON send/thread-reply, malformed or non-card fallback, and card JSON plus media rejection so this delivery decision is covered.
    Confidence: 0.9

Overall correctness: patch is incorrect
Overall confidence: 0.87

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 55323103b912.

Label changes

Label justifications:

  • P2: This is a focused Feishu channel regression fix with limited blast radius, but it affects user-visible proactive message delivery.
  • merge-risk: 🚨 message-delivery: The PR changes whether JSON-shaped Feishu proactive-send text is delivered as plain text or as an interactive card.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The PR body provides terminal source-wiring output and explicitly says live Feishu API interaction was not tested, so it does not prove after-fix real behavior. 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 +45, Tests +4. Total +49 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 3 48 3 +45
Tests 1 27 23 +4
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 75 26 +49

What I checked:

  • Repository policy read: Root and extension-scoped policy were read; the applicable guidance requires whole-path review, extension-boundary ownership, and real behavior proof for user-visible channel delivery changes. (AGENTS.md:9, 55323103b912)
  • Current main source reproduction: Current main reads text/message, builds a Feishu card only from normalized presentation, and otherwise routes the payload to sendMessageFeishu, so plain card JSON remains text. (extensions/feishu/src/channel.ts:780, 55323103b912)
  • Existing native card path: The outbound native-card sanitizer reads structured channelData.feishu.card or interactiveCard; it does not parse a plain text string into a card on current main. (extensions/feishu/src/outbound.ts:249, 55323103b912)
  • Shared runner stays provider-agnostic: The shared message runner parses structured presentation, delivery, and interactive parameters, then preserves plain message text as payload.text without synthesizing Feishu-specific channel data. (src/infra/outbound/message-action-runner.ts:1398, 55323103b912)
  • PR delivery change: The PR loads the Feishu channel runtime before delivery selection and calls runtime.tryParseFeishuCardFromText(text) before deciding between card, media, and text delivery. (extensions/feishu/src/channel.ts:789, 8f904195d65e)
  • Test coverage gap: The PR test diff changes the runtime mock to import the parser, but it does not add assertions for valid parsed-card routing, malformed or non-card fallback, thread replies, or card-plus-media rejection. (extensions/feishu/src/channel.test.ts:31, 8f904195d65e)

Likely related people:

  • vincentkoc: Authored and merged the Feishu message-tool change matching the regression window and the later native-card payload support this PR reuses. (role: recent Feishu message-action and native-card contributor; confidence: high; commits: 29ad211e7647, 2161b46032e0, 2ae84f75efde; files: extensions/feishu/src/channel.ts, extensions/feishu/src/outbound.ts, extensions/feishu/src/outbound.test.ts)
  • Gustavo Madeira Santana: History shows March work moving Feishu message-tool card/schema ownership into the plugin-owned channel path adjacent to this regression. (role: adjacent Feishu message-tool contributor; confidence: medium; commits: 60d4c5a30bf6, cac1c62208; files: extensions/feishu/src/channel.ts)
  • m1heng: The Feishu package metadata identifies the Feishu/Lark plugin as community maintained by this handle, making them a useful routing candidate for Feishu-domain review. (role: declared Feishu plugin contact; confidence: medium; files: extensions/feishu/package.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: 🦪 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: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. labels Jun 18, 2026
@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 Jun 18, 2026
@liuhao1024

Copy link
Copy Markdown
Contributor Author

The Real behavior proof CI check is now passing. Requesting ClawSweeper re-evaluation.

@liuhao1024

Copy link
Copy Markdown
Contributor Author

CI is green — all checks passing including Real behavior proof. Ready for ClawSweeper re-evaluation.

@liuhao1024

Copy link
Copy Markdown
Contributor Author

Auto-cleanup: freeing PR slots for higher-quality contributions. Feel free to reopen if still relevant.

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. P2 Normal backlog priority with limited blast radius. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S 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.

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

1 participant