fix(feishu): use interactive card messages for Markdown rendering#31804
Open
qiushile wants to merge 1 commit into
Open
fix(feishu): use interactive card messages for Markdown rendering#31804qiushile wants to merge 1 commit into
qiushile wants to merge 1 commit into
Conversation
Collaborator
14 tasks
6e12aa2 to
7c83a5f
Compare
Feishu's 'post' message type does not support the 'md' tag, causing Markdown formatting (bold, lists, code blocks) to render as plain text. Switch to 'interactive' (card) message type which has a proper markdown element that renders formatting correctly. Add _build_markdown_card_payload() to construct minimal card structures with markdown elements. Add _should_fallback_from_interactive() to handle card send failures (error codes 99992402/03/04, field validation errors) with graceful fallback to plain text messages. Adapt media caption and post payload builders to use the card format.
7c83a5f to
829bf99
Compare
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.
Problem
Feishu (Lark)
postmessage type does not support themd(Markdown) tag. When Hermes sends Markdown-formatted messages asposttype, formatting like bold, italic, lists, and code blocks renders as plain text — users see raw Markdown syntax instead of formatted output.Solution
Switch to Feishu
interactive(card) message type, which has a proper markdown element ({"tag": "markdown"}) that correctly renders all Markdown formatting.Changes
_build_markdown_card_payload()— New function that builds a minimal interactive card structure wrapping Markdown content in a propermarkdownelement_should_fallback_from_interactive()— New fallback handler for card send failures (error codes 99992402/03/04, field validation errors) with graceful degradation to plain text_resolve_message_type_and_payload()— Returnmsg_type="interactive"instead of"post"for Markdown content_build_media_post_payload()— Adapt media caption payloads to use the card format_build_post_payload()— Delegate to_build_markdown_card_payload()"post"→"interactive"with expanded error detectionTesting
Before: Markdown messages rendered as raw text with
**bold**,- lists, etc. visible.After: Messages render with proper formatting through Feishu card markdown element.