fix(feishu): WebSocket watchdog + approval card PATCH + markdown table rendering#10801
Open
bugmaker2 wants to merge 2 commits into
Open
fix(feishu): WebSocket watchdog + approval card PATCH + markdown table rendering#10801bugmaker2 wants to merge 2 commits into
bugmaker2 wants to merge 2 commits into
Conversation
…r card updates WebSocket watchdog (Bug #65/10616): - Added _ws_stopped flag to FeishuAdapter.__init__ - Modified _run_official_feishu_ws_client to set _ws_stopped=True when the lark-oapi WS client loop exits (ping timeout or unrecoverable error) - Added _feishu_ws_watchdog task in GatewayRunner that monitors _ws_stopped and raises SystemExit(1) so systemd can restart the process Approval card PATCH (Bug #66/10251): - Added PatchMessageRequest/PatchMessageRequestBody SDK imports - Added _build_patch_message_body and _build_patch_message_request builders - Added _patch_approval_card method that calls PATCH /im/v1/messages/{id} (instead of PUT) per Feishu API requirements for interactive cards - Updated _resolve_approval to call _patch_approval_card after resolving Also fixed (from merged markdown-fixer branch): - _build_outbound_payload: check _should_send_as_card before _MARKDOWN_HINT_RE so tables and code-heavy content always route to card format - _should_send_as_card: use multiline regex to count only opening fence lines (not closing fences), avoiding false positives from table separator rows Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…s_card() for tables - Remove _escape_markdown_text() calls from post rendering pipeline (_render_text_element, link labels, @-mentions, _render_nested_post). Feishu post "md" elements expect raw markdown; pre-escaping special characters like **, *, ` caused them to display literally. - Tables and code-heavy content (3+ code blocks) are routed to interactive card format via _should_send_as_card(), since Feishu post "md" elements do not support table syntax. - _build_markdown_card_payload() creates card payloads with "tag: markdown" elements for full markdown support. - _TABLE_RE detects markdown table separator rows for card routing. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
From my perspective, the existing callback response via P2CardActionTriggerResponse + CallBackCard already updates the card on button click — the only reason other chat members don't see the update "config": {"wide_screen_mode": True, "update_multi": True}, Also worth noting that the extra PATCH call might race with the callback update. |
13 tasks
This was referenced Apr 25, 2026
1 task
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.
What does this PR do?
Three related Feishu fixes:
WebSocket watchdog (fixes Feishu/Lark WebSocket drops lead to Zombie Gateway Process without auto-recovery #10616): When the lark-oapi WebSocket client's message loop exits due to ping timeout or unrecoverable error, the
FeishuAdaptersets_ws_stopped = True. A newGatewayRunner._feishu_ws_watchdog()task monitors this flag and raisesSystemExit(1)so systemd (or any supervisor withRestart=always) can respawn the gateway. This prevents zombie gateway processes that appear "running" but accept no messages.Approval card PATCH API (fixes Feishu command approval card buttons fail with error code 200340 #10251): The existing
_update_approval_card()usedim.v1.message.update(PUT) which replaces the entire message and strips interactive elements. Switched toim.v1.message.patch(PATCH) per Feishu API requirements for interactive card updates. Error 200340 was observed when using PUT.Markdown table rendering (fixes [Feishu] Markdown tables not rendering in Feishu messages #9549, fix(feishu): markdown tables not rendering as interactive cards — simplify
_should_send_as_card()trigger condition #9536, [Feishu Bug] Markdown source code displayed instead of rendered card format #7022): Feishu postmdelements do not support markdown table syntax. Content containing table rows (| --- |separator) is now routed to interactive card format withtag: markdownelements. Also fixed excessive markdown escaping — Feishu postmdelements expect raw markdown; pre-escaping special characters caused bold/italic/code to display literally.Related Issue
Fixes #10616 (WS watchdog)
Fixes #10251 (approval card PATCH)
Fixes #9549, #9536 (markdown tables)
Type of Change
Changes Made
gateway/platforms/feishu.py: Added_ws_stoppedflag toFeishuAdapter, WS watchdog signaling in_run_official_feishu_ws_client,PatchMessageRequest/PatchMessageRequestBodyimports,_patch_approval_card()method using PATCH API,_build_markdown_card_payload()for card format,_should_send_as_card()for table detection, removed excessive_escape_markdown_text()calls from post renderinggateway/run.py: Added_feishu_ws_watchdog()async task toGatewayRunner, started instart()tests/gateway/test_feishu.py: AddedTestFeishuWsWatchdogFlag,TestFeishuRunOfficialWsClientWatchdog, andTestAdapterBehaviortest methods for table/card markdown detectionHow to Test
python -m pytest tests/gateway/test_feishu.py -q -k "ws_watchdog or should_send_as_card"→ 3 passedChecklist
Code
fix(feishu):)pytest tests/gateway/test_feishu.py -q— 103 passed, 16 skipped, 2 failed (lark-oapi optional dep not installed in test env)Documentation & Housekeeping
docs/, docstrings) — N/A (no user-facing behavior change beyond fixing bugs)cli-config.yaml.exampleif I added/changed config keys — N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — N/A