Skip to content

fix(feishu): force text mode for markdown tables (salvage #13723)#20275

Merged
teknium1 merged 1 commit into
mainfrom
salvage/pr-13723
May 5, 2026
Merged

fix(feishu): force text mode for markdown tables (salvage #13723)#20275
teknium1 merged 1 commit into
mainfrom
salvage/pr-13723

Conversation

@teknium1

@teknium1 teknium1 commented May 5, 2026

Copy link
Copy Markdown
Contributor

Salvages @WuTianyi123's PR #13723 onto current main.

What it does

Feishu post-type md elements do not render markdown tables. When table content triggered the _MARKDOWN_HINT_RE path (because of nearby **bold** etc.), the message rendered blank on the client. Detect tables via a dedicated regex and force plain-text payload for those cases.

Changes

  • gateway/platforms/feishu.py — new _MARKDOWN_TABLE_RE + table early-return in _build_outbound_payload.

Validation

tests/gateway/test_feishu.py — 196 passed locally.

Closes #13723 via salvage.

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.
@denjones

denjones commented May 27, 2026

Copy link
Copy Markdown

@teknium1 Please revert the merge. Table rendered normally for me until this commit be merged.

huangyoje pushed a commit to huangyoje/hermes-agent that referenced this pull request Jun 6, 2026
…ards

Closes NousResearch#9549, NousResearch#19035. Supersedes NousResearch#23861.

## Problem

Feishu's post-type 'md' element does not render GFM tables and truncates
multi-line fenced code blocks. The current behaviour (force-text fallback,
PR NousResearch#20275) avoids the blank-message symptom but leaks raw markdown source
to the user — pipes, separators and code fences are visible as plain text.

## Approach

Route content containing GFM tables or multi-line fenced code blocks to
CardKit 2.0 interactive messages (schema: 2.0, tag: markdown), which
render both natively. Plain markdown without tables/code stays in post/md
as before.

Falls back to plain text when the interactive card is rejected (bot lacks
card permission, malformed payload, etc.) so failures degrade gracefully.

## ErrCode 11310: per-card table cap

CardKit 2.0 caps the total number of GFM tables across an entire card at
5. Exceeding this triggers ErrCode 11310 ('card table number over limit')
and the API rejects the whole card.

The cap is per-CARD, not per-element — verified empirically against the
live Feishu API on 2026-05-27. A single element with 6 tables fails. So
do two elements with 4+2 tables, three elements with 2+2+2, and a layout
with one table per element. Five tables in any layout pass.

When content has more than 5 tables, _build_outbound_messages() splits
it into multiple cards and send() iterates the resulting (msg_type,
payload) list. Splits cut at section boundaries — the first paragraph
break after the previous table block ends — so each table's heading and
lead-in prose travel into the same card as the table itself, rather than
being orphaned in the previous chunk.

## Tests

tests/gateway/test_feishu.py::TestCardTableLimitSplitting

- single card for ≤5 tables
- two cards for 6 tables (5 + 1)
- three cards for 12 tables (5 + 5 + 2)
- non-table content keeps post/text routing untouched
- prose between tables stays with the following table at split points

## Migration notes

- Bots without card-send permission will silently fall back to plain
  text (existing fallback path, extended for the interactive case).
- Edit_message remains on the single-payload path; streaming edits do
  not currently produce > 5 tables in a single chunk in practice.
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 type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants