Skip to content

Commit cfc3604

Browse files
committed
fix slack to include successful execs
1 parent b0457bc commit cfc3604

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

apps/sim/app/api/tools/slack/utils.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,6 @@ export async function uploadFilesToSlack(
8181
logger.info(`[${requestId}] Uploading file: ${userFile.name}`)
8282

8383
const buffer = await downloadFileFromStorage(userFile, requestId, logger)
84-
uploadedFiles.push({
85-
name: userFile.name,
86-
mimeType: userFile.type || 'application/octet-stream',
87-
data: buffer.toString('base64'),
88-
size: buffer.length,
89-
})
9084

9185
const getUrlResponse = await fetch('https://slack.com/api/files.getUploadURLExternal', {
9286
method: 'POST',
@@ -125,6 +119,13 @@ export async function uploadFilesToSlack(
125119

126120
logger.info(`[${requestId}] File data uploaded successfully`)
127121
uploadedFileIds.push(urlData.file_id)
122+
// Only add to uploadedFiles after successful upload to keep arrays in sync
123+
uploadedFiles.push({
124+
name: userFile.name,
125+
mimeType: userFile.type || 'application/octet-stream',
126+
data: buffer.toString('base64'),
127+
size: buffer.length,
128+
})
128129
}
129130

130131
return { fileIds: uploadedFileIds, files: uploadedFiles }

0 commit comments

Comments
 (0)