fix(gateway/feishu): always route outbound via post + md tag - #28030
Open
0x5446 wants to merge 1 commit into
Open
fix(gateway/feishu): always route outbound via post + md tag#280300x5446 wants to merge 1 commit into
0x5446 wants to merge 1 commit into
Conversation
The previous _build_outbound_payload had two heuristics that caused visible misrendering: 1. _MARKDOWN_TABLE_RE downgraded any message containing a GFM table to msg_type=text, which made the ENTIRE message (headers, bold, lists, code, the table itself) render as raw markdown source on both Lark and Feishu clients. 2. _MARKDOWN_HINT_RE over-matched on incidental punctuation (`_*#>` in shell output, code traces, prose) and under-matched on legitimate markdown that didn't fit its narrow patterns — yielding inconsistent styling. Empirical testing on current Lark (international) and Feishu (CN) clients shows the post-type `md` tag is a strict superset of msg_type=text: plain prose, URLs, mentions, emoji, multi-line text, special characters, and markdown tables all render correctly. The outer _feishu_send_with_retry already falls back to text if the API ever rejects a specific payload, so the safety net stays. Drops both regex constants and the conditional branching; one code path, one render mode. Regression test added for the table case (the most user-visible bug) and the plain-text case (to pin the strict-superset claim).
Collaborator
This was referenced May 20, 2026
Contributor
|
Thanks for the focused Feishu rendering investigation. The current table-to-text behavior is still present, but this patch needs rework before it can be safely salvaged. Problems
Suggested changes
This is an automated hermes-sweeper review. |
This was referenced Jun 24, 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_payloadpreviously used two regex heuristics to choose betweenmsg_type=textandmsg_type=post. Both heuristics produced visible misrendering:_MARKDOWN_TABLE_REforce-downgraded any message containing a GFM table tomsg_type=text. The downgrade made the entire message — headers, bold, lists, code, the table itself — render as raw markdown source on both Lark (international) and Feishu (CN) clients._MARKDOWN_HINT_REover-matched on incidental punctuation (_ * # >in shell output, stack traces, prose) and under-matched on legitimate markdown that didn't fit its narrow patterns — yielding inconsistent styling between similar-looking messages.Fix
Always route outbound messages through
post+ themdtag.Empirical testing on current Lark and Feishu clients shows the
mdtag is a strict superset ofmsg_type=text:mdtag resulttext_*#>)The outer
_feishu_send_with_retrystill catches the rare"content format of the post type is incorrect"API error and falls back tomsg_type=text, so the safety net stays.Drops both regex constants and the conditional branching — one code path, one render mode.
Tests
tests/gateway/test_feishu.py: 200/200 passtest_outbound_payload_routes_table_to_post_not_text— pins the table-bug fixtest_outbound_payload_plain_text_uses_post_md— pins the strict-superset claimtext-mode assertion that no longer appliesVerification
Validated end-to-end through the live gateway adapter (not a raw API bypass) on Lark international — plain text, special chars, URLs, multi-line+emoji, and a markdown table all rendered correctly.