Skip to content

fix: truncate long text in Slack approval card updates to avoid invalid_blocks - #35495

Closed
Yuki-14544869 wants to merge 1 commit into
NousResearch:mainfrom
Yuki-14544869:fix/slack-approval-truncation
Closed

fix: truncate long text in Slack approval card updates to avoid invalid_blocks#35495
Yuki-14544869 wants to merge 1 commit into
NousResearch:mainfrom
Yuki-14544869:fix/slack-approval-truncation

Conversation

@Yuki-14544869

Copy link
Copy Markdown

Problem

Slack's chat.update API rejects section blocks with text longer than 3000 characters (invalid_blocks / must be less than 3001 characters).

When code execution approval cards contain long code previews, the _handle_approval_action and _handle_slash_confirm_action handlers preserve the original text in updated_blocks. This can exceed the 3000-char limit and cause the chat_update to fail silently — leaving the approval buttons visible even after the user has successfully clicked them.

Reproduction

  1. Send a code execution approval request with a code preview >3000 chars
  2. Click any approval button (approve/deny)
  3. The approval is resolved (agent unblocks) but the buttons remain visible
  4. Gateway logs show: Failed to update approval message: invalid_blocks

Fix

Truncate original_text to 2900 characters + ellipsis when rebuilding the updated blocks in both handlers.

Changed files: gateway/platforms/slack.py (2 lines)

Logs

WARNING gateway.platforms.slack: [Slack] Failed to update approval message: The request to the Slack API failed. (url: https://slack.com/api/chat.update, status: 200)
The server responded with: {'ok': False, 'error': 'invalid_blocks', '1': 'must be less than 3001 characters [json-pointer:/blocks/0/text/text]'}

…k API invalid_blocks error

Slack's chat.update API rejects section blocks with text longer than
3000 characters (error: invalid_blocks / 'must be less than 3001
characters'). When code execution approval cards contain long code
previews, the _handle_approval_action and _handle_slash_confirm_action
handlers preserve the original text in updated_blocks, which can exceed
this limit and cause the message update to silently fail — leaving the
approval buttons visible even after the user has clicked them.

Fix: truncate original_text to 2900 characters + ellipsis when rebuilding
the updated blocks.
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery platform/slack Slack app adapter labels May 30, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Related to #35389 (competing fix, same approach) and #27441 (overloaded PR with same fix buried in 36 files). All three address the same Slack Block Kit 3000-char section text limit on approval card updates.

@Yuki-14544869
Yuki-14544869 deleted the fix/slack-approval-truncation branch June 7, 2026 02:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists platform/slack Slack app adapter type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants