Skip to content

fix(feishu): keep markdown tables in post payload so prose still renders - #22047

Closed
Tranquil-Flow wants to merge 2 commits into
NousResearch:mainfrom
Tranquil-Flow:fix/21778-feishu-table-rendering
Closed

fix(feishu): keep markdown tables in post payload so prose still renders#22047
Tranquil-Flow wants to merge 2 commits into
NousResearch:mainfrom
Tranquil-Flow:fix/21778-feishu-table-rendering

Conversation

@Tranquil-Flow

@Tranquil-Flow Tranquil-Flow commented May 8, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

v0.13.0 added a defensive fallback in _build_outbound_payload() that forces any reply containing a markdown table to send as plain text, on the rationale that Feishu's post-type md element doesn't render tables natively (#21778). The cure is worse than the disease — once the whole reply is plain text, every other markdown construct (headings, fences, bold, links, lists) renders as raw source on the Feishu client, not just the table.

This PR drops the table-detection downgrade. Replies with markdown go through the post pipeline as usual; the table itself still appears as raw markdown on the client (Feishu's md element limitation unchanged), but everything around it renders. Net UX is strictly better than the prior text fallback.

Related Issue

Closes #21778

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

  • gateway/platforms/feishu.py — remove table-detection branch from _build_outbound_payload(); remove the now-unused _MARKDOWN_TABLE_RE regex
  • tests/gateway/test_feishu.pyTestOutboundPayloadMarkdownTables (3 tests covering table → post, plain text → text, markdown without table → post)

How to Test

  1. pytest tests/gateway/test_feishu.py -q — 158 passed, 43 skipped
  2. pytest tests/gateway/test_feishu.py::TestOutboundPayloadMarkdownTables -v — 3 new tests pass
  3. The new tests fail on baseline (assert msg_type == "post" for table content vs. baseline "text")

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform: macOS 15

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — or N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — or N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — or N/A
  • I've updated tool descriptions/schemas if I changed tool behavior — or N/A

Screenshots / Logs

pytest tests/gateway/test_feishu.py -q
158 passed, 43 skipped

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery platform/feishu Feishu / Lark adapter labels May 11, 2026
Forcing every table-bearing reply to plain text (NousResearch#21778) made all
surrounding markdown — headings, fences, bold, links, lists — render
as raw source on the Feishu client.  The post-type `md` element
still does not natively render tables, so the table itself appears
as raw markdown, but the rest of the message renders normally.  Net
UX is strictly better than the prior text-fallback behaviour.
@Tranquil-Flow
Tranquil-Flow force-pushed the fix/21778-feishu-table-rendering branch from 8102b3b to a02edb9 Compare May 25, 2026 11:04
@teknium1

Copy link
Copy Markdown
Contributor

Thanks for targeting the real formatting regression.

Problems

  • Removing the fallback alone sends tables through _build_markdown_post_payload(), which emits a single tag: "md" element for unfenced content (plugins/platforms/feishu/adapter.py:565-588). The original fallback commit 8e18d10318f9fb69f0b748db11e37de44b71da85 records that this table payload appears blank on the Feishu client. The new routing assertion therefore restores the condition the fallback was added to avoid.
  • The PR now targets removed paths: 5600105478ffde29d7566b45421b100eaa29c4ef moved gateway/platforms/feishu.py to plugins/platforms/feishu/adapter.py. Its added test import needs the same port.

Suggested changes

  • Salvage this against plugins/platforms/feishu/adapter.py with a visible-table representation rather than deleting the fallback alone; the cross-referenced fix(feishu): wrap markdown tables in code_block tags for post rendering #22259 discusses a code-block approach.
  • Update the tests to import the bundled plugin and assert the generated payload uses the selected supported representation, not only msg_type == "post".

Automated hermes-sweeper review.

@teknium1 teknium1 added sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jul 13, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Closing — this was fixed on main by #68121, which removes the _MARKDOWN_TABLE_RE force-text downgrade and routes tables through post/md, the same direction as this PR. You were the earliest (May 8) to argue the downgrade's cure was worse than the disease and remove it — at the time Feishu hadn't yet fixed table rendering server-side, so the final fix waited on their API change, but the direction proved right. The salvage was based on #58019 (cleanest implementation vs current main, with tests) with #29552 credited as the earliest submitter against the live plugin adapter path; both authors' commits were cherry-picked with authorship preserved. Thanks for contributing a fix for this — it was one of the most-reported bugs in the tracker.

@teknium1 teknium1 closed this Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists platform/feishu Feishu / Lark adapter sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug Report: Feishu (Lark) Markdown Table Rendering Regression in v0.13.0

3 participants