Repository navigation
Conversation
Greptile SummaryThis PR extends
Confidence Score: 3/5Safe to merge after fixing the trailing-whitespace bug in the anchor-tag test; the core parsing logic is sound. The PR logic is correct for all described scenarios, but there is a concrete test failure in the anchor-tag test: input text "See: " (trailing space) will not match the asserted "See:" because individual texts are pushed untrimmed. The PR's stated test coverage is not actually green. extensions/feishu/src/send.ts line 220-221 — tag:"text" node text should be trimmed before pushing. extensions/feishu/src/send.test.ts line 257/275 — input and expected value are inconsistent. Prompt To Fix All With AIThis is a comment left during a code review.
Path: extensions/feishu/src/send.test.ts
Line: 257-275
Comment:
**Test/code mismatch — trailing whitespace in text causes assertion failure**
The test input at line 257 has `{ tag: "text", text: "See: " }` — note the trailing space. The production code in `send.ts` pushes `node.text` directly (not trimmed):
```typescript
if (node.tag === "text" && typeof node.text === "string" && node.text.trim()) {
texts.push(node.text); // pushes "See: " with the trailing space intact
}
```
After `texts.join("\n")`, the result is `"Report\nSee: \nWeekly Report (...)"` — but the assertion expects `"Report\nSee:\nWeekly Report (...)"` (no trailing space). The `.trim()` call at the end only strips the leading/trailing edges of the whole string, not interior segments.
This test will fail as written. The fix is to trim the individual text value before pushing in `send.ts`:
```suggestion
if (node.tag === "text" && typeof node.text === "string" && node.text.trim()) {
texts.push(node.text.trim());
}
```
This is also better UX — stray trailing spaces in card text are noise and shouldn't appear in the extracted content.
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "fix(feishu): parse interactive card post..." | Re-trigger Greptile |
| { tag: "text", text: "See: " }, | ||
| { tag: "a", text: "Weekly Report", href: "https://example.com/report" }, | ||
| ], | ||
| ], | ||
| }), | ||
| }, | ||
| }, | ||
| ], | ||
| }, | ||
| }); | ||
|
|
||
| const result = await getMessageFeishu({ | ||
| cfg: {} as ClawdbotConfig, | ||
| messageId: "om_card_links", | ||
| }); | ||
|
|
||
| expect(result).toEqual( | ||
| expect.objectContaining({ | ||
| content: "Report\nSee:\nWeekly Report (https://example.com/report)", |
There was a problem hiding this comment.
Test/code mismatch — trailing whitespace in text causes assertion failure
The test input at line 257 has { tag: "text", text: "See: " } — note the trailing space. The production code in send.ts pushes node.text directly (not trimmed):
if (node.tag === "text" && typeof node.text === "string" && node.text.trim()) {
texts.push(node.text); // pushes "See: " with the trailing space intact
}After texts.join("\n"), the result is "Report\nSee: \nWeekly Report (...)" — but the assertion expects "Report\nSee:\nWeekly Report (...)" (no trailing space). The .trim() call at the end only strips the leading/trailing edges of the whole string, not interior segments.
This test will fail as written. The fix is to trim the individual text value before pushing in send.ts:
| { tag: "text", text: "See: " }, | |
| { tag: "a", text: "Weekly Report", href: "https://example.com/report" }, | |
| ], | |
| ], | |
| }), | |
| }, | |
| }, | |
| ], | |
| }, | |
| }); | |
| const result = await getMessageFeishu({ | |
| cfg: {} as ClawdbotConfig, | |
| messageId: "om_card_links", | |
| }); | |
| expect(result).toEqual( | |
| expect.objectContaining({ | |
| content: "Report\nSee:\nWeekly Report (https://example.com/report)", | |
| if (node.tag === "text" && typeof node.text === "string" && node.text.trim()) { | |
| texts.push(node.text.trim()); | |
| } |
This is also better UX — stray trailing spaces in card text are noise and shouldn't appear in the extracted content.
Prompt To Fix With AI
This is a comment left during a code review.
Path: extensions/feishu/src/send.test.ts
Line: 257-275
Comment:
**Test/code mismatch — trailing whitespace in text causes assertion failure**
The test input at line 257 has `{ tag: "text", text: "See: " }` — note the trailing space. The production code in `send.ts` pushes `node.text` directly (not trimmed):
```typescript
if (node.tag === "text" && typeof node.text === "string" && node.text.trim()) {
texts.push(node.text); // pushes "See: " with the trailing space intact
}
```
After `texts.join("\n")`, the result is `"Report\nSee: \nWeekly Report (...)"` — but the assertion expects `"Report\nSee:\nWeekly Report (...)"` (no trailing space). The `.trim()` call at the end only strips the leading/trailing edges of the whole string, not interior segments.
This test will fail as written. The fix is to trim the individual text value before pushing in `send.ts`:
```suggestion
if (node.tag === "text" && typeof node.text === "string" && node.text.trim()) {
texts.push(node.text.trim());
}
```
This is also better UX — stray trailing spaces in card text are noise and shouldn't appear in the extracted content.
How can I resolve this? If you propose a fix, please make it concise.|
Thanks for the context here. I did a careful shell check against current Close: this older PR is no longer the best landing path because current main now solves the central Feishu read-card failure by requesting full card content on both single-message and thread-history reads, while the remaining fallback-parser diff is proof-blocked and carries an external-input recursion risk. So I’m closing this older PR as already covered on Review detailsBest possible solution: Keep the current-main full-card-content request from #93134 and route broader inbound/card-action parsing decisions through #41609 or narrower follow-ups. Do we have a high-confidence way to reproduce the issue? Yes. Source inspection shows the original degraded Feishu card payload fell through the parser, while current main now avoids that read path by requesting full card JSON on both get and list calls. Is this the best way to solve the issue? No, this branch is no longer the best fix. The better current-main solution is to request Feishu's full card content at the API boundary; any remaining degraded-payload parser work should be bounded and separately proven. Security review: Security review needs attention: The diff has no supply-chain changes, but it adds unbounded recursive parsing over external Feishu card payloads.
AGENTS.md: found and applied where relevant. What I checked:
Likely related people:
Codex review notes: model internal, reasoning high; reviewed against da92615816b6; fix evidence: commit 1db8ab373422, main fix timestamp 2026-06-15T12:04:55+08:00. |
db76951 to
a380eb1
Compare
|
ClawSweeper PR egg 🎁 Pass real behavior proof to wake the egg and unlock a hatchable treat. Where did the egg go?
|
|
Heads up: this PR needs to be updated against current |
|
This pull request has been automatically marked as stale due to inactivity. |
|
ClawSweeper applied the proposed close for this PR.
|
Summary
Fix
parseInteractiveCardContent()to handle Feishu API post-format fallback content for interactive card messages.Fixes #60380
Related: #41609 #48281
Problem
When reading card messages via
GET /im/v1/messages/{message_id}, Feishu returnsbody.contentin a post-style fallback format — nested arrays withtag:"text"elements — instead of the original card template JSON. The existing parser only handled card template format (div/markdowntags), causing all fallback content to silently return"[Interactive Card]".Before: Any
message(action=read)on a card →"[Interactive Card]"After: Extracts title + text content from both card template and post-format fallback
Example
API returns this for a card message:
{ "title": "🤖 clawdbot", "elements": [[ {"tag": "img", "image_key": "img_v3_02ad_..."}, {"tag": "text", "text": "Daily report summary"}, {"tag": "text", "text": "13 people missing reports"} ]] }"[Interactive Card]""🤖 clawdbot\nDaily report summary\n13 people missing reports"Changes
extensions/feishu/src/send.tselements(post-format fallback[[...]])tag:"text"andtag:"a"elements from fallback contentheader.title.content(template) or top-leveltitle(fallback)tag:"plain_text"elementsextensions/feishu/src/send.test.tsheader.title.contenttag:"a"elements with hrefTesting