fix(feishu): correct fence boundaries, expand fallback, and force text mode for tables#13723
Closed
WuTianyi123 wants to merge 2 commits into
Closed
fix(feishu): correct fence boundaries, expand fallback, and force text mode for tables#13723WuTianyi123 wants to merge 2 commits into
WuTianyi123 wants to merge 2 commits into
Conversation
Collaborator
|
Related to #12512 (merged) which first split fenced code blocks into post rows — this PR fixes edge cases in that logic. |
1 similar comment
Collaborator
|
Related to #12512 (merged) which first split fenced code blocks into post rows — this PR fixes edge cases in that logic. |
added 2 commits
April 22, 2026 08:31
…fallback coverage
- Replace simple regex fence matching with char+length tracking to avoid
mis-interpreting inner fences (e.g. a ended the code block prematurely,
causing malformed post payloads and silent message drops.
Feishu post-type 'md' elements do not render markdown tables. When table content is sent as post (triggered by **bold** matching _MARKDOWN_HINT_RE), the message appears blank on the client. Add _MARKDOWN_TABLE_RE to detect markdown table syntax and force text mode for table content, ensuring it is visible as plain text.
0b96f24 to
b76b1af
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.
Summary
Fixes two distinct classes of Feishu message delivery failures where markdown content causes messages to be swallowed or appear blank on the client.
Problem 1: Fenced code block boundary mis-detection
_build_markdown_post_rowsused naive regex^```\s*$to detect open/close fences. This fails for:``````) — inner```lines were mistaken for close fences~~~) — not recognized at all````) — close regex didn't matchResult: Code blocks truncated early or never closed, corrupting post JSON → "消息类型不合法" or blank messages.
Problem 2: Markdown tables sent as post appear blank
When a message contains both
**bold**(matching_MARKDOWN_HINT_RE) and a markdown table, the entire content is sent asposttype. Feishu'smdtag does not render markdown table syntax — the message appears completely blank on the client.Result: Users cannot see anything for table-containing messages.
Changes
Fence boundary detection — replaced naive regex with
fence_char+fence_lenstate tracking (CommonMark compliant). Open/close fences must use the same character and closing length must be ≥ opening length.Post→text fallback — ty-agent lacked fallback logic entirely; hermes only caught English errors. Expanded
_POST_CONTENT_INVALID_REto cover Chinese error messages and added robust fallback to plain text.Table detection — added
_MARKDOWN_TABLE_REto detect markdown table syntax (|...|+ separator line). Forcestexttype for table content, ensuring it displays as plain text instead of being swallowed.Test Plan
_MARKDOWN_TABLE_REcorrectly identifies tables while avoiding false positives on non-table markdowntextpayload format for table content is valid JSONfence_len+_MARKDOWN_TABLE_REBackwards Compatibility
No breaking changes. Messages without tables or code blocks behave identically. Table messages now consistently use
texttype instead of unreliableposttype.Related Issues
Fixes message-swallowing bugs in Feishu adapter when sending markdown tables or nested fenced code blocks.