fix(feishu): stop downgrading messages with tables to plain text - #52986
Open
BravianZhao wants to merge 1 commit into
Open
fix(feishu): stop downgrading messages with tables to plain text#52986BravianZhao wants to merge 1 commit into
BravianZhao wants to merge 1 commit into
Conversation
The Feishu post-type 'md' renderer now handles markdown tables natively on lark-oapi 1.5.x + Feishu/Lark client V7+, but _build_outbound_payload was still force-routing any message containing a table to msg_type=text to avoid a (long-fixed) blank-message bug. The unintended side-effect: every other markdown feature in the same reply -- headings, bold, fenced code, inline code, links, lists -- also got stripped because the whole message became plain text. A research summary that happened to include one comparison table came out as a wall of raw markdown. Route markdown content (tables included) through the existing _build_markdown_post_payload pipeline. _build_markdown_post_rows already splits on fenced code, so tables now render alongside prose, code, and emoji in a single message. Verified on Feishu desktop (China region, Lark domain) with lark-oapi 1.5.3: two markdown tables with right-aligned numerics and emoji, a fenced Python code block, headings, bold, lists, inline code, and a link all render correctly in one reply. Adds 4 unit tests covering plain text, plain markdown, bare table, and composite-with-table routing decisions.
Collaborator
Duplicate of #52790 — same minimal mechanism (stop force-downgrading table-bearing markdown to |
This was referenced Jul 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
FeishuAdapter._build_outbound_payloadforce-routes any message containing a markdown table tomsg_type=textto avoid an old blank-message bug. Side-effect: every other markdown feature in the same reply -- headings, bold, fenced code, inline code, links, lists -- also gets stripped, because the whole message becomes plain text.A research summary that happens to include one comparison table comes out as a wall of raw
**bold**,`code`,## headingand|---|characters.Root cause
The protective table-downgrade dates back to a real client bug, but Feishu's
post-typemdelement renders markdown tables natively on lark-oapi 1.5.x + Feishu/Lark client V7+. The downgrade is now pessimistic: it punishes every non-table markdown element in the message to guard against a problem that no longer exists.Fix
Route any markdown content (tables included) through the existing
_build_markdown_post_payloadpipeline._build_markdown_post_rowsalready splits on fenced code, so tables now coexist with prose, code, links, and emoji in a single message._MARKDOWN_TABLE_REis kept (as a hint that table-only content is still markdown) so a bare table without any other markdown still flows throughpostinstead of falling to plain text.Verification
Verified on Feishu desktop (China region, Lark domain) with
lark-oapi 1.5.3by sending the same composite reply twice -- once astext, once aspost:##headings,**bold**, bulleted list, inline`code`, and a[link](https://...).msg_type=text(old behaviour): everything renders as literal markdown characters.msg_type=post(new behaviour): every feature including both tables renders natively.Tests added in
tests/gateway/test_feishu.py::TestOutboundPayloadRouting:test_plain_text_uses_text_msg_type"hello world"texttest_plain_markdown_uses_post_msg_type**bold**+ linkposttest_markdown_table_alone_uses_post_msg_typepost(regression)test_markdown_table_with_surrounding_content_keeps_postpost(regression)All 4 pass on Python 3.11.15:
Rollback
Single-file fix in
plugins/platforms/feishu/adapter.py. Revert the commit to restore the previous downgrade behaviour if a regression on an older Feishu client is reported.Risk
Low. The post path was already in use for every other markdown message; this PR only widens the input set it accepts. If an old client without table support exists in the wild, the table cells fall through as plain text inside an otherwise correctly rendered post message -- strictly better than today's outcome where the entire message degrades to raw markdown.