fix(feishu): serialize approval callback card data to JSON string#10256
Open
stephenlzc wants to merge 2 commits into
Open
fix(feishu): serialize approval callback card data to JSON string#10256stephenlzc wants to merge 2 commits into
stephenlzc wants to merge 2 commits into
Conversation
The Feishu API expects CallBackCard.data to be a JSON string, not a Python dict. When _handle_approval_card_action() assigned a dict to card.data, the Lark SDK serialized it as a nested object, causing Feishu to reject the card action response with error code 200340. Fix by wrapping the resolved card dict in json.dumps(..., ensure_ascii=False), matching how outgoing interactive cards are already handled in send_exec_approval(). Also updated test assertions to verify card.data is a string and to json.loads() it before inspecting contents. Fixes NousResearch#10251
13 tasks
13 tasks
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.
Summary
Fixes the Feishu (Lark) command approval card buttons failing with error code 200340.
Problem
When a dangerous command triggered the
⚠️ Command Approval Requiredinteractive card in Feishu, clicking any button (Allow Once, Session, Always, Deny) resulted in a Feishu client error:The agent thread remained blocked, and the command was never resolved.
Root Cause
_handle_approval_card_action()ingateway/platforms/feishu.pybuilt aCallBackCardand assigned a Python dict tocard.data:However, the Feishu API expects
card.datato be a JSON string. The Lark SDK serialized the dict as a nested JSON object, which Feishu rejected with error 200340.Fix
Wrapped the card dict in
json.dumps(..., ensure_ascii=False)before assigning tocard.data, matching how outgoing interactive cards are already handled insend_exec_approval():Tests
Updated
tests/gateway/test_feishu_approval_buttons.pyto assert that:response.card.datais astr(not a dict).json.loads().All 18 Feishu approval-button tests pass.
Related Issue
Fixes #10251
Checklist