fix(feishu): use real card message ID for synthetic card-action events - #85864
fix(feishu): use real card message ID for synthetic card-action events#85864DavidMetcalfe wants to merge 4 commits into
Conversation
_handle_card_action_event built the synthetic COMMAND event with the card callback token (or a random UUID) as message_id. The token is a short-lived card-update credential, not an IM message ID, so the processing-status reaction (_add_reaction via on_processing_start) and the reply anchor (_reply_anchor_for_event) both failed: reactions never appeared and agent responses were rejected by Feishu with error 99992354. The callback payload carries the original card message's real ID in event.context.open_message_id. Use it, falling back to the token only when the payload omits it. Closes NousResearch#7200 Co-authored-by: sline <151105947+0xsline@users.noreply.github.com>
53427f7 to
d70f6ce
Compare
fix(feishu): use real card message ID for synthetic card-action events The fix direction is correct: the card callback token is a short-lived card-update credential, not an IM message ID, so preferring
|
The callback token is not a valid IM message ID; when a payload omits open_message_id the synthetic event is routed with the token, which fails downstream (reaction + reply anchor, Feishu 99992354). Emit a debug log on that path so future reports are diagnosable without re-deriving the cause.
Extend the open_message_id regression test to assert the reply anchor (_reply_anchor_for_event) and the processing-status reaction (on_processing_start -> _add_reaction) both resolve from the real card message ID, and the token-fallback test to pin its reply anchor. The event.message_id field alone is the plumbing; these assertions lock the issue NousResearch#7200 symptom.
|
@Enough1122 — addressed all three points; two accepted with clarifications and one declined.
One note for future readers: since card actions on the same card share |
Summary
Fixes #7200 — Feishu card button clicks show no reaction feedback.
When a user clicks an interactive card button,
_handle_card_action_eventbuilds a syntheticCOMMANDevent. It used the card callback token (a short-lived card-update credential, not an IM message ID) asevent.message_id. Downstream that breaks two things:on_processing_start→_add_reaction(event.message_id, "Typing")calls FeishuCreateMessageReactionwith the token, which is not a valid message ID, so the API rejects it and the user sees no feedback (the issue's reported symptom)._reply_anchor_for_eventreturnsevent.message_idfor Feishu, so responses are sent withreply_to=<token>and Feishu rejects them with error99992354(invalid open_message_id).The card callback payload already carries the original card message's real ID in
event.context.open_message_id(the adapter already readsopen_chat_idfrom the sameCallBackContext). This PR uses it, falling back to the previous token/UUID behavior only when the payload omits it.What this PR does
plugins/platforms/feishu/adapter.py: readcontext.open_message_idin_handle_card_action_eventand use it as the synthetic event'smessage_id(card_message_id or token or str(uuid.uuid4())).tests/gateway/test_feishu_approval_buttons.py: fixture now carriesopen_message_id; new test asserts the synthetic event uses it (RED before fix, GREEN after) and that the reply anchor and the processing-status reaction resolve from it; new test asserts token fallback when the field is absent.Design decisions
message_idassignment changes. TheMessageType.COMMANDtype and/card {tag}synthetic text are untouched — the issue is about the reaction ID, and fix(feishu): stop using card action callback token as synthetic message_id #43609 verified live that COMMAND-type synthetic events do reach the agent.open_message_id, behavior is identical to today (token, then UUID), so malformed callbacks don't regress. A debug log on that path (added per review) keeps future 99992354 reports diagnosable.open_message_id, so the existing in-flight skip inon_processing_start(message_id in _pending_processing_reactions) now dedups duplicate Typing badges on the same card message as intended;on_processing_completeremoves the badge and cache entry by message ID.Notes
open_message_iddirection) targets the pre-migrationgateway/platforms/feishu.pypath and bundles text/type changes — it needs a migration-aware rebase; fix(feishu): stop using card action callback token as synthetic message_id #43609 and fix(feishu): custom interactive card button-click round-trip #43048 setmessage_id=None, which prevents the reaction feedback that [Bug]: 接收飞书卡片的回调过程中,没有正确获取原始卡片消息的 ID 来添加表情 #7200 asks for. This PR is the narrow fix on the current plugin path.Verification
AssertionError: 'c-card-update-credential' == 'om_original_card_msg'), passes after.message_id=card_message_id or ...→message_id=token or ...) fails the new test with'c-card-update-credential' == 'om_original_card_msg'; restored →test_feishu_approval_buttons.py15 passed.tests/gateway/test_feishu.py test_feishu_approval_buttons.py test_feishu_meeting_invite.py test_text_batching.py→ 85 passed, 18 skipped.git diff origin/main...HEAD --stat: 2 files, +86/−2.