fix(feishu): render markdown tables via post+md, not text downgrade - #58019
fix(feishu): render markdown tables via post+md, not text downgrade#58019JasonFang1993 wants to merge 1 commit into
Conversation
Resolves issue NousResearch#52786 (duplicate of NousResearch#23938): The `_build_outbound_payload` shortcut forced any message containing a pipe table to ``msg_type=text``. Feishu readers then rendered the raw pipe-and-dash source instead of a table. Empirically current Feishu clients render markdown tables inside ``post``-type ``md`` elements natively, so the downgrade branch had to go. Two changes: 1. ``_MARKDOWN_HINT_RE`` now also matches a pipe-table header+separator pair, so a table-only message is recognised as "has markdown" and takes the ``post`` path. All previously recognised hints (headings, lists, code, bold/italic/strike/underline, links, blockquotes, hr) still match — verified by the existing 205 test_feishu.py cases plus the new regression tests below. 2. ``_build_outbound_payload`` no longer special-cases `_MARKDOWN_TABLE_RE` before the hint check. The hint check now routes table content to `_build_markdown_post_payload`, which is the same path any other markdown structure takes. ``_MARKDOWN_TABLE_RE`` itself is retained as a module-level constant for external callers (import-path-sensitive tests, third-party consumers of the adapter module) and continues to work for its existing uses. Tests ----- New: ``tests/gateway/test_feishu_table_markdown.py`` — four regression tests: - ``test_markdown_table_uses_post_not_text`` — pure-table content reaches ``post`` (issue NousResearch#52786 scenario). - ``test_table_combined_with_other_markdown_does_not_downgrade`` — prose + table + prose message keeps its surrounding markdown. - ``test_existing_markdown_heading_still_uses_post`` — sanity guard: the heading path is unchanged. - ``test_plain_text_without_markdown_still_uses_text`` — negative control: pure prose still goes to ``text``. Verification ------------ ``pytest tests/gateway/test_feishu.py tests/gateway/test_feishu_table_markdown.py`` passes 209/209 (205 existing + 4 new), three consecutive runs. Rollback -------- ``git reset --hard 44ddc55`` restores upstream main without the new test file.
|
Hi! Submitting this as a fix for the table-downgrade branch in A quick note on where this PR sits in the existing cluster of "feishu
I deliberately did not touch any of the in-flight Quick verification locally (with this branch): (205 pre-existing + 4 new regression tests.) Happy to iterate on the test surface or refactor any of the |
Duplicate of #52790 — same code site ( |
|
Merged via #68121 — your commit was cherry-picked onto current main with your authorship preserved in git log. Your implementation was the cleanest of the 9 competing fixes (current plugin path, hint-regex extension, regression tests using the required loader helper) and served as the base of the salvage. Thanks! |
Summary
Fixes #52786 and fixes #23938, closing the duplicate cluster around #31056.
_build_outbound_payloadinplugins/platforms/feishu/adapter.pywas force-downgrading any message containing a markdown pipe table tomsg_type=text, so Feishu readers rendered the raw pipe-and-dash source instead of a table. Empirically current Feishu clients render markdown tables insidepost-typemdelements natively, so the downgrade branch had to go.Changes
_MARKDOWN_HINT_REnow also matches a pipe-table header + separator pair, so a table-only message is recognised as "has markdown" and takes thepostpath._build_outbound_payloadno longer special-cases_MARKDOWN_TABLE_REbefore the hint check. Table content now flows through the same_build_markdown_post_payloadpath as every other markdown structure (headings, lists, code, bold, links, etc.)._MARKDOWN_TABLE_REitself is retained as a module-level constant for backwards compatibility with external callers.Tests
New file:
tests/gateway/test_feishu_table_markdown.py(4 regression tests).test_markdown_table_uses_post_not_text— pure-table content →post, with table text inside anmdelement (issue Feishu adapter incorrectly downgrades markdown tables to plain text #52786 scenario)test_table_combined_with_other_markdown_does_not_downgrade— prose + table + prose message keeps its surrounding markdowntest_existing_markdown_heading_still_uses_post— heading path unchangedtest_plain_text_without_markdown_still_uses_text— negative controlThe new tests use the projects
tests/gateway/_plugin_adapter_loader.load_plugin_adapter()helper, as required by the conftest plugin-adapter anti-pattern guard.Verification
→ 209 passed (205 existing + 4 new), three consecutive runs.
Rollback
restores upstream main without the new test file.
Related