Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internal error with files_upload_v2 #1653

Open
jbonjean opened this issue Feb 12, 2025 · 3 comments
Open

Internal error with files_upload_v2 #1653

jbonjean opened this issue Feb 12, 2025 · 3 comments
Labels
needs info An issue that is claimed to be a bug and hasn't been reproduced, or otherwise needs more info server-side-issue

Comments

@jbonjean
Copy link

jbonjean commented Feb 12, 2025

There seems to be a limit of 14 files with files.completeUploadExternal, and I receive an internal error when exceeding it.

Reproducible in:

The Slack SDK version

slack_sdk==3.34.0

Python runtime version

Python 3.12.3

OS info

#53-Ubuntu SMP PREEMPT_DYNAMIC Sat Jan 11 00:06:25 UTC 2025

Steps to reproduce:

The following script runs with 14 as argument, and fails with 15.

import os
import sys

from slack_sdk import WebClient

SLACK_TOKEN = os.getenv("SLACK_TOKEN")
SLACK_CHANNEL_ID = os.getenv("SLACK_CHANNEL_ID")

client = WebClient(SLACK_TOKEN)
client.auth_test()

file_uploads_count = int(sys.argv[1])

print(f"Uploading {file_uploads_count} files")

file_uploads = [
    {
        "content": "Sample content",
        "filename": f"file-{i}.txt",
    }
    for i in range(1, file_uploads_count + 1)
]

client.files_upload_v2(
    channel=SLACK_CHANNEL_ID,
    file_uploads=file_uploads,
    initial_comment=f"{file_uploads_count} files",
)

Expected result:

It should work like the now deprecated files.upload followed by chat.postMessage.

Actual result:

Traceback (most recent call last):
  File "/work/slack-upload-v2/./slack-upload-v2.py", line 25, in <module>
    client.files_upload_v2(
  File "/venvs/slack-upload-v2/lib/python3.12/site-packages/slack_sdk/web/client.py", line 3844, in files_upload_v2
    completion = self.files_completeUploadExternal(
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/venvs/slack-upload-v2/lib/python3.12/site-packages/slack_sdk/web/client.py", line 3898, in files_completeUploadExternal
    return self.api_call("files.completeUploadExternal", params=kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/venvs/slack-upload-v2/lib/python3.12/site-packages/slack_sdk/web/base_client.py", line 159, in api_call
    return self._sync_send(api_url=api_url, req_args=req_args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/venvs/slack-upload-v2/lib/python3.12/site-packages/slack_sdk/web/base_client.py", line 190, in _sync_send
    return self._urllib_api_call(
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/venvs/slack-upload-v2/lib/python3.12/site-packages/slack_sdk/web/base_client.py", line 321, in _urllib_api_call
    ).validate()
      ^^^^^^^^^^
  File "/venvs/slack-upload-v2/lib/python3.12/site-packages/slack_sdk/web/slack_response.py", line 199, in validate
    raise e.SlackApiError(message=msg, response=self)
slack_sdk.errors.SlackApiError: The request to the Slack API failed. (url: https://slack.com/api/files.completeUploadExternal)
The server responded with: {'ok': False, 'error': 'internal_error'}
@jbonjean jbonjean changed the title internal_error with files.completeUploadExternal Internal error with files_upload_v2 Feb 12, 2025
@misscoded misscoded added needs info An issue that is claimed to be a bug and hasn't been reproduced, or otherwise needs more info server-side-issue and removed untriaged labels Feb 13, 2025
@misscoded
Copy link
Contributor

Hi @jbonjean! Thanks for submitting this. After some digging, it's not clear what limitation is being bumped up against here, especially given the vagueness of the server error. We recommend contacting support and having them look at the server-side logs to get a better idea as to what's happening here.

@jbonjean
Copy link
Author

jbonjean commented Feb 14, 2025

Hi, thank you for looking into this so quickly, I'll forward the issue to their support.

In case somebody else encounters this issue, my workaround for now has been to use files_upload_v2 with batches of 14 files max, without giving a channel, then gather all the permalinks and use chat.postMessage (like I was doing with v1).

@jbonjean
Copy link
Author

I received a response from their support team. It's a limitation of their system, and they will likely document it and improve the error message at some point. For now, their recommendation is to include no more than 10 files in files.completeUploadExternal calls.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs info An issue that is claimed to be a bug and hasn't been reproduced, or otherwise needs more info server-side-issue
Projects
None yet
Development

No branches or pull requests

2 participants