Skip to content

fix(slack): truncate inflated original_text in approval/confirm chat.update handlers (#53693) - #53701

Closed
liuhao1024 wants to merge 18 commits into
NousResearch:mainfrom
liuhao1024:liuhao/cron-bugfix-53693-slack-approval-truncation
Closed

fix(slack): truncate inflated original_text in approval/confirm chat.update handlers (#53693)#53701
liuhao1024 wants to merge 18 commits into
NousResearch:mainfrom
liuhao1024:liuhao/cron-bugfix-53693-slack-approval-truncation

Conversation

@liuhao1024

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes Slack approval and confirmation card updates failing with invalid_blocks: must be less than 3001 characters when 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) extract original_text from the interaction payload and rebuild updated_blocks verbatim. 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, causing chat.update to fail silently while the approval itself has already resolved.

Related Issue

Fixes #53693

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)

Changes Made

  • plugins/platforms/slack/adapter.py: Cap original_text to 3000 chars after extraction from interaction payload in both _handle_approval_action and _handle_slash_confirm_action. This matches the send-path budget and prevents entity-inflation overflow.
  • tests/gateway/test_slack_approval_buttons.py: Add test_truncates_inflated_original_text to both TestSlackApprovalAction and TestSlackSlashConfirmAction -- inject 3040-char inflated text and assert the chat.update section block stays at 3000 chars or fewer.

How to Test

  1. Run 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.
  2. On a Slack-connected Hermes instance, trigger a command approval with HTML-heavy content (e.g. execute_code with Python comparisons). Press "Allow Once" -- the card should update to show "Approved" without errors.
  3. Check gateway logs for "Failed to update approval message" -- should not appear for the inflated-text case.

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/gateway/test_slack_approval_buttons.py -v and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform: macOS

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — or N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — or N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — or N/A
  • I've updated tool descriptions/schemas if I changed tool behavior — or N/A

…update handlers

Slack re-escapes HTML entities in the interaction payload
(< -> &lt;, > -> &gt;, & -> &amp;), 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
@alt-glitch alt-glitch added type/bug Something isn't working comp/gateway Gateway runner, session dispatch, delivery comp/plugins Plugin system and bundled plugins platform/slack Slack app adapter sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages P2 Medium — degraded but workaround exists labels Jun 27, 2026
@teknium1

Copy link
Copy Markdown
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!

@teknium1 teknium1 closed this Jul 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/install-update Installer, updater, packaging, wheels, doctor comp/gateway Gateway runner, session dispatch, delivery comp/plugins Plugin system and bundled plugins P2 Medium — degraded but workaround exists platform/slack Slack app adapter sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Slack approval/confirm card chat.update fails (invalid_blocks >3000) after button press; approval resolves but card never updates

3 participants