fix(slack): truncate inflated original_text in approval/confirm chat.update handlers (#53693) - #53701
Closed
liuhao1024 wants to merge 18 commits into
Closed
Conversation
…update handlers Slack re-escapes HTML entities in the interaction payload (< -> <, > -> >, & -> &), inflating the section text past the 3000-char Block Kit limit when the button handler rebuilds updated_blocks for chat.update. The send path already budget-truncates, but the click handlers used the echoed original_text verbatim. Cap it to 3000 chars in both _handle_approval_action and _handle_slash_confirm_action. Fixes NousResearch#53693
This was referenced Jul 9, 2026
Closed
Contributor
|
Merged via #69317 — your commit was cherry-picked onto current main with your authorship preserved in git history: your approval/confirm original_text truncation was cherry-picked directly. Thanks for the contribution! |
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?
Fixes Slack approval and confirmation card updates failing with
invalid_blocks: must be less than 3001 characterswhen the original command/prompt text contains HTML-sensitive characters (angle brackets, ampersands).The send path (
send_exec_approval,send_slash_confirm) already budget-truncates section text to 3000 chars or fewer. But the button click handlers (_handle_approval_action,_handle_slash_confirm_action) extractoriginal_textfrom the interaction payload and rebuildupdated_blocksverbatim. Slack re-escapes HTML entities in the payload (e.g.&for&,<for the left angle bracket), inflating the text past the 3000-char section-block limit, causingchat.updateto fail silently while the approval itself has already resolved.Related Issue
Fixes #53693
Type of Change
Changes Made
plugins/platforms/slack/adapter.py: Caporiginal_textto 3000 chars after extraction from interaction payload in both_handle_approval_actionand_handle_slash_confirm_action. This matches the send-path budget and prevents entity-inflation overflow.tests/gateway/test_slack_approval_buttons.py: Addtest_truncates_inflated_original_textto bothTestSlackApprovalActionandTestSlackSlashConfirmAction-- inject 3040-char inflated text and assert thechat.updatesection block stays at 3000 chars or fewer.How to Test
python -m pytest tests/gateway/test_slack_approval_buttons.py -v-- all 28 tests should pass, including the 2 new truncation tests. Observed result: 28 passed in 2.63s.execute_codewith Python comparisons). Press "Allow Once" -- the card should update to show "Approved" without errors.Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/gateway/test_slack_approval_buttons.py -vand all 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/A