fix(feishu): serialize card.data to JSON string for approval/update-prompt responses#42465
Open
liuhao1024 wants to merge 1 commit into
Open
fix(feishu): serialize card.data to JSON string for approval/update-prompt responses#42465liuhao1024 wants to merge 1 commit into
liuhao1024 wants to merge 1 commit into
Conversation
…rompt responses Feishu API expects card.data to be a JSON string, but _build_resolved_approval_card() and _build_resolved_update_prompt_card() return dicts. The raw dict assignment causes error 200340 when users click approval or update-prompt buttons on interactive cards. Fix: wrap both assignments with json.dumps(ensure_ascii=False). Fixes NousResearch#38305
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?
Serializes
card.datato a JSON string in both_handle_approval_card_actionand_handle_update_prompt_card_actioncallbacks. The Feishu API requirescard.datato be a JSON string, but both handlers were passing raw Python dicts, causing error 200340 when users click approval or update-prompt buttons on interactive cards.Related Issue
Fixes #38305, Fixes #10251, Fixes #10073, Fixes #8246, Fixes #13924
Type of Change
Changes Made
gateway/platforms/feishu.py: Wrapcard.dataassignments in_handle_approval_card_action(line 2639) and_handle_update_prompt_card_action(line 2696) withjson.dumps(ensure_ascii=False)so the Feishu API receives a JSON string instead of a Python dict.tests/gateway/test_feishu_approval_buttons.py: Update 6 test assertions to verifycard.datais astr(viaisinstancecheck) and parse it withjson.loads()before accessing dict keys.How to Test
pytest tests/gateway/test_feishu_approval_buttons.py -v— all 38 tests pass/updateprompt → click "Yes" or "No" → card should update without error 200340Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/gateway/test_feishu_approval_buttons.py -vand all 38 tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/ACode Intelligence
gateway/platforms/feishu.py→_handle_approval_card_action,_handle_update_prompt_card_action,_build_resolved_approval_card,_build_resolved_update_prompt_card_build_resolved_approval_card: 1 (line 2639)_build_resolved_update_prompt_card: 1 (line 2696)_handle_update_prompt_card_actionhandler that fix(feishu): serialize approval callback card data to JSON string #10256 missed.