From f21d34d71d7609c4d071eb824ccfc3ae453507fc Mon Sep 17 00:00:00 2001 From: Ilya Kuprov <166841386+IlyaKuprov@users.noreply.github.com> Date: Sat, 15 Aug 2026 08:58:55 +0100 Subject: [PATCH] fix(slack): upload-file silently drops a caption (#121047) The Slack `upload-file` action accepts `media` as an alias for `filePath`, so a caller can reach it with the same vocabulary used for a media `send`. That vocabulary carries its accompanying text in `caption`, but the upload path read only `initialComment` and `message`, so the text was dropped and the file arrived in the channel with no comment at all. Accept `caption` as the lowest-precedence alias. Explicit `initialComment` still wins, `message` still comes next, and an explicitly empty higher-precedence value stays empty. --- .../slack/src/message-action-dispatch.test.ts | 26 +++++++++++++++++++ .../slack/src/message-action-dispatch.ts | 4 +++ 2 files changed, 30 insertions(+) diff --git a/extensions/slack/src/message-action-dispatch.test.ts b/extensions/slack/src/message-action-dispatch.test.ts index 9f2182d14e84..4069cc22a805 100644 --- a/extensions/slack/src/message-action-dispatch.test.ts +++ b/extensions/slack/src/message-action-dispatch.test.ts @@ -738,6 +738,32 @@ describe("handleSlackMessageAction", () => { initialComment: "path alias", }, }, + { + name: "maps an upload-file caption to the upload's initial comment", + params: { + channelId: "C1", + media: "/tmp/chart.png", + caption: "chart attached", + }, + expected: { + filePath: "/tmp/chart.png", + initialComment: "chart attached", + }, + }, + { + name: "prefers an explicit upload-file initial comment over message and caption", + params: { + channelId: "C1", + media: "/tmp/chart.png", + initialComment: "", + message: "message text", + caption: "caption text", + }, + expected: { + filePath: "/tmp/chart.png", + initialComment: "", + }, + }, ])("$name", async ({ params, expected }) => { const invoke = createInvokeSpy(); const cfg = slackConfig(); diff --git a/extensions/slack/src/message-action-dispatch.ts b/extensions/slack/src/message-action-dispatch.ts index 6e04d82d132c..086aff2e343d 100644 --- a/extensions/slack/src/message-action-dispatch.ts +++ b/extensions/slack/src/message-action-dispatch.ts @@ -358,6 +358,10 @@ export async function handleSlackMessageAction(params: { initialComment: readStringParam(actionParams, "initialComment", { allowEmpty: true }) ?? readStringParam(actionParams, "message", { allowEmpty: true }) ?? + // `media` is accepted as an alias for the file, so a send-shaped call + // arrives with its text in `caption`; without this alias that text is + // silently dropped instead of becoming the upload's first comment. + readStringParam(actionParams, "caption", { allowEmpty: true }) ?? "", filename: readStringParam(actionParams, "filename"), title: readStringParam(actionParams, "title"),