slackapi/python-slack-sdk

Slack python client uploading blank files

DPLATA opened this issue ยท 21 comments

I'm using the following python/slack_sdk code to upload a series of files to a slack channel:

from slack_sdk import WebClient

WebClient(token=os.getenv('SLACK_LOGGING_BOT_TOKEN')).files_upload_v2(channel=channel_id,initial_comment=initial_comment,file=file_name)

Uploading works, the problem is that sometimes one or multiple of those files are showing up blank (like in the picture attached) on slack but I'm 100% sure they are populated
blank file

This one is a csv file like the following:

Statistic Value
Signups 24
Churns 14
Net Activations 10

If I download the file from slack is also empty.

I'm not posting this as a bug because I can't even consistently reproduce the bug so I don't know how to solve it. Any ideas of what is going on?

How big are these CSV files you are uploading, typically, @DPLATA ? I will try on my end to see if I can reproduce. Also, what sorts of failure rates for these uploads are you seeing, more or less?

I've started seeing the same thing over the last week - code in question hasn't really changed in the last few months, I'm using slack-sdk==3.21.3 and the upload is a small CSV.

Either the upload works, or just the filename is listed but it's empty - as in the OP's initial report - or...there's nothing.

I can replicate it by just running the following consecutively:

from slack_sdk import WebClient
web_client = WebClient(token="xoxb-XXXXX")
web_client.files_upload_v2(channel="XXXXX", filename="something.csv", content="things,stuff\nbits,bobs\n")

Sometimes the uploads appear, sometimes they appear empty, sometimes they don't appear at all - at the moment they're mostly not appearing at all with the occasional upload where it's OK.

The responses in both a success and a failure are "ok": true.

Upgrading to slack-sdk==3.22.0 and there's no change. Below is some of the output where something actually appeared in the channel (there were plenty of calls where nothing turned up at all):

image

In use I have two things that run 3 times weekly that upload a CSV - the last two times they ran they both failed to uploaded anything at all.
It all seems very intermittent, but the "not seeing anything" rate (as I type this when testing) is over 50% in about 20 test calls.

OK, I was able to reproduce on my small production Slack workspace on my 11th try:

Screenshot 2023-09-22 at 9 13 35 AM

I've escalated with the backend team in charge of the File APIs. Will report back what we hear in the investigation. Note that given it is a Friday when I reported it, I wouldn't expect to hear back until next week, so your patience is appreciated ๐Ÿ™

Noted that is being reported.
Just for adding more details the sdk version I'm using is: slack_sdk==3.21.3 and same as @cotman the responses in both a success and a failure are "ok": true and the failure rate is about 50% of the time and my files are around 6 KB

Just for additional context on this, my 2 3-times weekly automated jobs that upload files to Slack ran this morning.
One uploaded its CSV file correctly, one produced a blank file.

fyi just got the same thing while uploading and sending over a csv file manually

@DPLATA manually, as in, via the Slack client / the message composer?

yes over a slack chat, I dragged and dropped the file to the message composer and send it. I send it twice first time it appeared blank

I'm able to reproduce that as well right now.

FYI we are still investigating this bug, it is reproducible in a variety of our internal environments, though only intermittently, making it a challenge to identify the root cause. As I hear more about progress, I will keep this issue informed.

The same issue is happening.
I use slack sdk 3.19.5.

Yes, investigations are still ongoing. This issue is still a problem, using the Slack client directly or via the API.

is there any update on this?

I'd kind of expected to see this reflected on the Slack system status page, given that it impacts both the API and the client, but:
image

Our backend team is still investigating the issue.

Quick update: a race condition was identified in smaller file uploads (less than 1MB) which causes this issue.

The team is addressing the issue and we expect a resolution in the coming days.

I will keep this issue posted as progress happens.

A fix is currently undergoing testing. We expect a resolution soon - I am hoping this week!

Adding cases to the task. I am experiencing the same issue. For me the file format is json, which is different for the case issuer's csv. As in the above description, this does not happen consistently and hard to reproduce but it does happen every now and then. I also confirmed that the uploadFile body is fulfilled but it does not show in slack
image

Another update: we have a fix that has passed testing and is in the final review stages. Earlier I mentioned the fix potentially landing this week - likely not, that was my mistake, apologies. However, progress is being made.
Thanks for your patience!

Hello!

Apologies for the delay here, but the fix was deployed at around 9AM Pacific Standard Time on Monday, October 9th.

In my local testing, I am no longer able to reproduce this.

I will close this issue now but feel free to re-open if you see problems here.

Many thanks to everyone for the reports and assistance in reproducing and providing details!