Description
When using files_upload_v2 with the alt_txt field in file_uploads, files are uploaded successfully but silently fail to be shared to the specified channel. Removing alt_txt resolves the issue.
Environment
- slack-sdk version: 3.39.0
- Python version: 3.12
- OS: Xubuntu 24.04.3 LTS
Steps to Reproduce
from slack_sdk import WebClient
slack_client = WebClient(token="xoxb-...")
# Read PDF file content
with open("report.pdf", "rb") as f:
pdf_content = f.read()
# Attempt to upload with alt_txt
files_to_upload = [{
"content": pdf_content,
"filename": "report.pdf",
"title": "Test Report",
"alt_txt": "Content of the Test Report for model version 1.0.0", # This causes the issue
}]
response = slack_client.files_upload_v2(
channels=["XXXXXXXXXXX"], # Valid channel ID where bot is a member
file_uploads=files_to_upload,
initial_comment="Test upload with alt_txt"
)
print(response)
Expected Behavior
- Files should be uploaded AND shared to the specified channel
- The
initial_comment message should appear in the channel
- Response should include the files with populated
shares, channels fields
Actual Behavior
- Files are uploaded successfully (
response['ok'] is True)
- Files are NOT shared to the channel (no message appears)
- Response shows empty sharing fields:
'shares': {}
'channels': []
'groups': []
'ims': []
- The bot CAN post messages to the channel using
chat_postMessage with the same channel ID
- No error is raised, making the issue difficult to debug
Workaround
Remove the alt_txt field from file_uploads:
files_to_upload = [{
"content": pdf_content,
"filename": "report.pdf",
"title": "Test Report",
# "alt_txt": "...", # REMOVED - causes silent failure
}]
response = slack_client.files_upload_v2(
channels=["XXXXXXXXXXX"],
file_uploads=files_to_upload,
initial_comment="Test upload without alt_txt"
)
With this change, files are successfully shared to the channel.
Additional Context
- Tested with both
channel= and channels=[] parameters - both exhibit the same issue when alt_txt is present
- The issue appears to be specific to the
files.completeUploadExternal step in the files_upload_v2 workflow
alt_txt is documented in the SDK's FileUploadTypeDef as an optional field for accessibility (screen readers)
- This may be related to PDF files specifically (not tested with other file types)
Questions
- Is
alt_txt fully supported in the v2 file upload API (files.completeUploadExternal)?
- Should there be validation or a warning when
alt_txt causes sharing to fail?
- Is this a known limitation with certain file types (PDFs)?
Impact
This issue makes it difficult to create accessible file uploads with proper alt text for screen readers when using the v2 upload API. The silent failure mode also makes debugging extremely challenging.
Description
When using
files_upload_v2with thealt_txtfield infile_uploads, files are uploaded successfully but silently fail to be shared to the specified channel. Removingalt_txtresolves the issue.Environment
Steps to Reproduce
Expected Behavior
initial_commentmessage should appear in the channelshares,channelsfieldsActual Behavior
response['ok']isTrue)chat_postMessagewith the same channel IDWorkaround
Remove the
alt_txtfield fromfile_uploads:With this change, files are successfully shared to the channel.
Additional Context
channel=andchannels=[]parameters - both exhibit the same issue whenalt_txtis presentfiles.completeUploadExternalstep in thefiles_upload_v2workflowalt_txtis documented in the SDK'sFileUploadTypeDefas an optional field for accessibility (screen readers)Questions
alt_txtfully supported in the v2 file upload API (files.completeUploadExternal)?alt_txtcauses sharing to fail?Impact
This issue makes it difficult to create accessible file uploads with proper alt text for screen readers when using the v2 upload API. The silent failure mode also makes debugging extremely challenging.