Skip to content

fix(feishu): send markdown tables as post instead of forcing plain text - #57538

Closed
xielevi wants to merge 1 commit into
NousResearch:mainfrom
xielevi:fix/feishu-table-post-rendering
Closed

fix(feishu): send markdown tables as post instead of forcing plain text#57538
xielevi wants to merge 1 commit into
NousResearch:mainfrom
xielevi:fix/feishu-table-post-rendering

Conversation

@xielevi

@xielevi xielevi commented Jul 3, 2026

Copy link
Copy Markdown

Problem

When Hermes sends a Feishu message containing a markdown table, _build_outbound_payload detects the table via _MARKDOWN_TABLE_RE and forces msg_type="text". This renders the table as raw pipe-delimited text (| col | col |), which is strictly worse than any alternative.

Related issues: #21866, #27469

Fix

Remove the table→text fallback and let tables take the same post path as other markdown content. The _MARKDOWN_TABLE_RE regex now triggers the post branch (alongside _MARKDOWN_HINT_RE) instead of the text fallback.

# Before
if _MARKDOWN_TABLE_RE.search(content):
    text_payload = {"text": content}
    return "text", json.dumps(text_payload, ensure_ascii=False)
if _MARKDOWN_HINT_RE.search(content):
    return "post", _build_markdown_post_payload(content)

# After
if _MARKDOWN_HINT_RE.search(content) or _MARKDOWN_TABLE_RE.search(content):
    return "post", _build_markdown_post_payload(content)

Safety

The existing send_message() method already catches post payload rejections from the Feishu API (_POST_CONTENT_INVALID_RE) and falls back to plain text with _strip_markdown_to_plain_text(). This safety net remains intact — if the post payload is rejected, the user still gets the message, just without formatting.

Testing

Verified with the following markdown elements in Feishu client — all render correctly:

Element Status
Headers (H1-H3)
Bold / Italic / Strikethrough
Ordered / Unordered lists
Code blocks (fenced)
Inline code
Blockquotes
Tables
Links
Horizontal rules

Notes

  • For users with hermes-lark-streaming plugin installed, this code path is typically bypassed (streaming cards set already_sent=True), but the fix ensures correct behavior for all users regardless of plugin setup.
  • The more comprehensive solution proposed in [feishu] Unified fix for markdown rendering: inbound escaping + GFM table → Card 2.0 #27469 (using msg_type="interactive" Card 2.0 for tables) would be a separate enhancement. This PR is the minimal fix that removes the actively harmful fallback.

The _build_outbound_payload method detected markdown tables via
_MARKDOWN_TABLE_RE and forced msg_type="text", which rendered tables
as raw pipe-delimited text (| col | col |). This is strictly worse
than sending as post — Feishu's post md tag now renders tables
correctly, and the existing fallback in send_message() already
catches post payload rejections and retries as plain text.

The table detection regex is still used: it now triggers the post
path (same as other markdown hints) instead of the text fallback.

Tested with headers, lists, code blocks, tables, links, blockquotes
— all render correctly in Feishu client.

Refs: #21866, #27469
@alt-glitch alt-glitch added type/bug Something isn't working comp/plugins Plugin system and bundled plugins platform/feishu Feishu / Lark adapter sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages P3 Low — cosmetic, nice to have duplicate This issue or pull request already exists labels Jul 3, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Duplicate of #27922 — this is part of the long-standing Feishu markdown-table rendering cluster (meta #27469). At least six open PRs (#27922, #28030, #31410, #34181, #36637, #38867) apply the same fix: remove the _MARKDOWN_TABLE_RE→text force-fallback in _build_outbound_payload() and route tables through the post path. #27922 is the earliest open PR with this approach and is treated as canonical. Flagging the cluster for a maintainer to pick one.

@xielevi

xielevi commented Jul 3, 2026

Copy link
Copy Markdown
Author

Closing as duplicate of #27922. Same fix (remove _MARKDOWN_TABLE_RE→text fallback, route tables through post path) already proposed in at least 6 open PRs (#27922, #28030, #31410, #34181, #36637, #38867). #27922 is canonical.

@xielevi xielevi closed this Jul 3, 2026
@xielevi
xielevi deleted the fix/feishu-table-post-rendering branch July 3, 2026 06:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/plugins Plugin system and bundled plugins duplicate This issue or pull request already exists P3 Low — cosmetic, nice to have platform/feishu Feishu / Lark adapter sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants