Skip to content

Slack media resolver only returns first file when message has multiple attachments #2348

Description

@lanceretter

Bug Description

When a Slack message contains multiple file attachments, resolveSlackMedia() only returns the first successfully downloaded file instead of all files.

Location

/dist/slack/monitor/media.js (source: src/slack/monitor/media.ts)

Problem

The function loops through files but returns immediately after the first successful download:

for (const file of files) {
    // ... download logic ...
    return {  // <-- BUG: Returns after FIRST file
        path: saved.path,
        contentType: saved.contentType,
        placeholder: label ? \`[Slack file: ${label}]\` : "[Slack file]",
    };
}

Impact

When another bot (e.g., TommyBot) sends multiple PDFs in a single message, Clawdbot only receives and processes the first one. This broke a workflow where invoice PDFs were being sent for processing.

Suggested Fix

Change the function to:

  1. Collect all successfully downloaded files into an array
  2. Return all files (requires updating the return type/interface)
  3. Update callers to handle multiple files

Reproduction

  1. Have another bot send a Slack message with 3+ file attachments
  2. Observe that Clawdbot only receives/processes the first file

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions