Skip to content

files_upload_v2 doesn't work with CarouselBlock #1917

Description

@sealogfish

I am trying to upload multiple base64 files to Slack using client.files_upload_v2(). The files are uploaded successfully but I am unable to render them in a CarouselBlock. I have no issues rendering the files as ImageBlocks. Does CarouselBlock support private Slack files?

Reproducible in:

The Slack SDK version

slack-bolt==1.18.0
slack_sdk==3.35.0

Python runtime version

Python 3.10.10

(Paste the output of python --version)

OS info

ProductName: macOS
ProductVersion: 26.5.2
BuildVersion: 25F8

Steps to reproduce:

  1. client.files_info() to check if the file has been uploaded by checking the mimetype and filetype. I extract and return the permalink generated.
  2. Populate the CarouselBlock with the code below:
    def build_chart_carousel_blocks(self, charts) -> list[dict[str, Any]]:
        """
        Builds and returns a chart carousel block.
        """
        cards = []
        for chart in charts:
            cards.append(CardBlock(
                hero_image=ImageBlock(
                    slack_file=SlackFile(url=chart.permalink),
                    alt_text=chart.title,
                ).to_dict(),
                title=PlainTextObject(text=chart.title),
            ))

        return [CarouselBlock(elements=cards).to_dict()]
  1. Send the message using the blocks parameter in client.chat_postMessage()

Expected result:

The Carousel is rendered with the successfully upload Slack file object

Actual result:

This results in a Carousel rendered as follows:
Image

I do not encounter this issue when I render and send an ImageBlock instead. The only workaround I managed to find was adding channel and thread_ts as a parameter to files_upload_v2(). However, this will result in double images being sent (once by the file upload command, and a second time when I render the Carousel block), which is not ideal.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions