Skip to content

fix(feishu): render markdown tables as aligned code blocks instead of raw text - #32648

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

fix(feishu): render markdown tables as aligned code blocks instead of raw text#32648
notwitcheer wants to merge 1 commit into
NousResearch:mainfrom
notwitcheer:fix/feishu-markdown-table-rendering

Conversation

@notwitcheer

Copy link
Copy Markdown
Contributor

What does this PR do?

Closes #32607.

Feishu's post-type md elements cannot render GFM pipe tables. The adapter previously fell back to plain text mode for the entire message when any markdown table was detected, losing all other markdown formatting (bold, italic, code blocks, lists, links).

This PR converts markdown tables to aligned monospaced code blocks in-place, so:

  • Tables are readable (padded columns, Unicode separator line)
  • Surrounding markdown formatting is preserved (sent as post, not text)
  • Tables inside existing fenced code blocks are left untouched

Before (raw text fallback)

| Column A | Column B | Column C |
|----------|----------|----------|
| Value 1  | Value 2  | Value 3  |

After (aligned code block)

Column A  Column B  Column C
────────  ────────  ────────
Value 1   Value 2   Value 3

Related Issue

Closes #32607.

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✅ Tests (adding test coverage)

Changes Made

  • gateway/platforms/feishu.py:
    • New _split_table_row(), _render_table_as_code_block(), and _convert_tables_to_code_blocks() helpers (same pattern as Telegram's _wrap_markdown_tables)
    • _build_outbound_payload() now converts tables to code blocks instead of falling back to "text" type
  • tests/gateway/test_feishu.py — 4 new tests (TestFeishuTableConversion): simple table conversion, non-table passthrough, code-block-guarded tables, and outbound payload type check.

How to Test

pytest tests/gateway/test_feishu.py::TestFeishuTableConversion -v

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(feishu):)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this bug fix
  • I've added tests for my changes (4 new tests)
  • Follows the same pattern used by the Telegram adapter (_wrap_markdown_tables)

… raw text

Feishu's post-type 'md' elements cannot render GFM pipe tables.  The
adapter previously fell back to plain text mode for the entire message,
losing all other markdown formatting.

Convert tables to aligned monospaced code blocks in-place so tables
are readable and the surrounding markdown is preserved as a post.

Closes #32607

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@alt-glitch alt-glitch added type/bug Something isn't working comp/gateway Gateway runner, session dispatch, delivery platform/feishu Feishu / Lark adapter P2 Medium — degraded but workaround exists labels May 26, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Part of the saturated Feishu markdown table rendering cluster tracked at #27469. Canonical issue: #9549, canonical PR: #12114. Competing with #21872 (aligned code fences), #20580 (closed, monospace code blocks — same approach), and #32488 (Schema 2.0 cards). This PR takes the code-block approach which overlaps with #20580 and #21872.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists platform/feishu Feishu / Lark adapter type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feishu messages: markdown tables not rendered, making them unreadable

2 participants