fix(feishu): render markdown tables as Card v2 native table components - #61496
fix(feishu): render markdown tables as Card v2 native table components#61496jerryjiao wants to merge 1 commit into
Conversation
Feishu post-type 'md' elements do not support markdown table syntax.
Previously, table content was downgraded to plain text (showing raw
| col | pipes). This patch converts markdown tables to Feishu
Interactive Card (v2) with native table components.
Key format requirements (from official docs):
- rows use object format: {col_0: val} NOT arrays [[cell]]
- columns require display_name + data_type fields
- card requires schema: '2.0' + body.elements wrapper
Supports mixed content (text + table + text) and multiple tables.
Falls back to plain text if conversion fails.
Duplicate of #12114 (earliest open) — same file ( |
tonydwb
left a comment
There was a problem hiding this comment.
Code Review Summary
Verdict: Comment
Overview
- Feishu: renders markdown tables as Card v2 native table components
- Small fix (+160/-4)
Looks Good
- Clean feature improvement
- No security concerns
Reviewed by Hermes Agent
teknium1
left a comment
There was a problem hiding this comment.
Thanks for addressing a real Feishu rendering gap: current main still forces detected tables into a plain-text payload at plugins/platforms/feishu/adapter.py:4524-4534.
Problems
plugins/platforms/feishu/adapter.py:4528and the new splitter at PR line 4674 are not fence-aware. A fenced code sample containing a pipe table will be converted into a native table card, changing code-block content. Current main explicitly supports code blocks (plugins/platforms/feishu/adapter.py:1426) and preserves fence-like content intests/gateway/test_feishu.py:2729.- The PR changes only the adapter and adds no regression tests for the new Card v2 path.
Suggested changes
- Exclude fenced code blocks from table detection/splitting.
- Add payload-level tests for table, mixed/multiple-table, malformed, and fenced-code inputs.
Automated hermes-sweeper review.
| # Feishu post-type 'md' elements do not render markdown tables. | ||
| # When a table is detected, convert it to an Interactive Card (v2) | ||
| # with native table components so it renders properly in Feishu. | ||
| if _MARKDOWN_TABLE_RE.search(content): |
There was a problem hiding this comment.
This regex also matches a pipe table inside a fenced code block, then _split_content_with_tables() turns the code sample into a native table. Please make detection fence-aware; current main declares supports_code_blocks = True and has code-block preservation coverage in tests/gateway/test_feishu.py:2729.
Problem
Feishu (Lark) post-type
mdelements do not support markdown table syntax. When an agent response contains a GFM markdown table (| col1 | col2 |), the current code downgrades the entire message to plain text — showing raw pipe characters to users instead of a rendered table.This affects every Hermes user on Feishu/Lark who receives table-formatted responses from agents.
Root Cause
In
plugins/platforms/feishu/adapter.py,_build_outbound_payload()detects tables via_MARKDOWN_TABLE_REbut falls back to"text"type payload — which strips all formatting.Solution
Convert detected markdown tables into Feishu Interactive Card v2 with native
tablecomponents.Key format requirements (from official Feishu docs):
rows[[cell, cell]]array{col_0: val}object per rowcolumns{name, width}only{name, display_name, data_type, width}{config, elements}{schema: "2.0", config, body: {elements}}Features:
markdown+table**bold**markers from table cellsRelated PRs
tablecomponent #12114 — duplicate of feat(feishu): render markdown tables as native CardKit v2 table components #17006Testing
Tested on Hermes v0.18.2 with real Feishu DM conversations. Tables now render as native interactive cards with proper column alignment and header styling.