From 72da4f8657ef26451fccb8d1210c812db3e03315 Mon Sep 17 00:00:00 2001 From: CJ Wang / SoWork Date: Wed, 22 Jul 2026 03:54:26 -0700 Subject: [PATCH] fix(slack): truncate edit_message content to prevent msg_too_long MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Slack's chat.update enforces the same ~40k character limit as chat.postMessage, but edit_message sent the formatted text unchunked — an oversized edit failed outright with msg_too_long and the message was never updated. Unlike send() we cannot split an edit into multiple messages, so truncate to MAX_MESSAGE_LENGTH via the shared chunker (which preserves code-block boundaries) and keep the first chunk. Reapplied from PR #33224 (targeted the pre-plugin gateway/platforms/slack.py path) onto plugins/platforms/slack/adapter.py. --- plugins/platforms/slack/adapter.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/plugins/platforms/slack/adapter.py b/plugins/platforms/slack/adapter.py index 8796ccabfda7..867b8ae9c6c3 100644 --- a/plugins/platforms/slack/adapter.py +++ b/plugins/platforms/slack/adapter.py @@ -1701,6 +1701,12 @@ class SlackAdapter(BasePlatformAdapter): return SendResult(success=False, error="Not connected") try: formatted = self.format_message(content) + # Slack's chat.update has the same ~40k char limit as postMessage. + # Unlike send() we can't split into multiple messages (we're + # editing an existing one), so truncate to fit — an oversized + # payload fails the whole edit with ``msg_too_long``. + chunks = self.truncate_message(formatted, self.MAX_MESSAGE_LENGTH) + formatted = chunks[0] if chunks else formatted update_kwargs: Dict[str, Any] = { "channel": chat_id, "ts": message_id,