Closed soilmo closed 6 months ago
Hey @soilmo , we are investigating this. We are seeing elevated rates of this error; our engineering teams are looking into the issue. Once I have more info I'll post here again.
Thanks! I'll be waiting for good news.
@soilmo I can't reproduce the error you are seeing with the payload you provided in your original post. Are you still seeing this?
@filmaj i tried again and got the same error.
Let me explain better about my situation:
I created a slack bot using Slack Bolt. It works well, but today after lunch, some functions doesn't work. All functions the send images happened this problem.
See print below to understand better:
OK, we were very much struggling with how this error could happen without an image being included in the blocks
payload!
Can you please post the blocks
payload that is causing the error? Based on your screenshot it seems you are uploading a file. Specifically: what field of the uploaded file / file object are you passing into the what field of the image block?
Sure!
The block is below:
say(
blocks = [
{
"type": "section",
"text": {
"type": "plain_text",
"text": 'Última atualização: '+str(infos[1])+' '+str(infos[2]) + ' | ITD do IPCA é o mesmo do FOCUS FIC FIA (2020-12-28)'
},
"accessory": {
"type": "image",
"slack_file": {
"url": infos[0]
},
"alt_text": "Rentabilidades"
}
}
]
)
Where:
infos[0] = "https://files.slack.com/files-pri/T01J6BY2VEU-F06ERESRXUZ/rentabilidades.png?pub_secret=aa3396340f"
Whoa, you're already using "slack_file": { "url": infos[0] }
? We just released that as a brand new feature, like, 4 hours ago?
We believe the issue may be the pub_secret
querystring param. Try dropping that?
Also: where are you getting that URL from?
Nice! Exactly! My problem was started about 4 hours ago.
My URL is been created like this:
client = WebClient(token=SLACK_USER_OAUTH_TOKEN)
result = client.files_upload(channel=channel_id,file=path, initial_comment = 'Carteira')
result_url = client.files_sharedPublicURL(file = result['file']['id'])
website = result_url['file']['permalink_public'].split("https://slack-files.com/")[1]
team_id = website.split('-')[0]
file_id = website.split('-')[1]
pub_secret = website.split('-')[2]
filename = result_url['file']['name']
direct_link = "https://files.slack.com/files-pri/" + team_id + "-" + file_id + "/" + filename + "?pub_secret=" + pub_secret
Your suggest is do the following?
client = WebClient(token=SLACK_USER_OAUTH_TOKEN)
result = client.files_upload(channel=channel_id,file=path, initial_comment = 'Carteira')
result_url = client.files_sharedPublicURL(file = result['file']['id'])
website = result_url['file']['permalink_public'].split("https://slack-files.com/")[1]
team_id = website.split('-')[0]
file_id = website.split('-')[1]
filename = result_url['file']['name']
direct_link = "https://files.slack.com/files-pri/" + team_id + "-" + file_id + "/" + filename
OK, according to our docs for slack_file
:
slack_file.url
| string | This URL can be theurl_private
or thepermalink
of the Slack file.
So try using permalink
rather than permalink_public
. Now with the slack_file
support, you shouldn't need to explicitly call sharedPublicURL
since the new "secure image" feature lets you use un-shared files as image sources within Slack.
Also curious: what was your solution here before the switch to slack_file
? The reason I ask is that, if you experienced this issue, I assume other developers probably did, too. It would be good to see the before/after code to see where we can improve the docs / tools to guide developers better.
Appreciate you working through this with me 🙏
Sure! I appreciate contribute into this task!
But i dont fix error yet. Now, i tried like this:
client = WebClient(token=SLACK_USER_OAUTH_TOKEN)
result = client.files_upload(channel=channel_id,file=path, initial_comment = 'Rentabilidades')
result_url = client.files_sharedPublicURL(file = result['file']['id'])
website = result_url['file']['permalink']
print(website)
And the block used was:
say(
blocks = [
{
"type": "section",
"text": {
"type": "plain_text",
"text": 'Última atualização: '+str(infos[1])+' '+str(infos[2]) + ' | ITD do IPCA é o mesmo do FOCUS FIC FIA (2020-12-28)\n'
},
"accessory": {
"type": "image",
"slack_file": {
"url": infos[0]
},
"alt_text": "Rentabilidades"
}
}
]
)
I got the same error:
Note that infos[0] = "https://indiecapitalworkspace.slack.com/files/U01HSA5NLH4/F06F1SJ08SC/rentabilidades.png"
OK, different error. Looking into it...
What kind of token is being used? A bot token or a user token? Does your app implement OAuth flow to retrieve user tokens to make actions on behalf of a user?
I use a bot token to create WebClient object and Bot User OAuth Token when i upload image on slack cloud.
Maybe use these differents codes in the same bot can make this error.
That's a bit of a confusing answer 😅 What I need to know is, do you use an xoxb-...
or an xoxp-...
token for each of the different Slack API calls? (files.upload, files.sharedPublicURL, chat.postMessage)
Oh, sorry. But yes. Let me show you:
SLACK_BOT_TOKEN: xoxb-... SLACK_USER_OAUTH_TOKEN: xoxp-...
OK great, that's what I needed to know. And for the chat.postMessage
API, which token is used?
Hi @filmaj ! Sorry my late.
So, i used say method to send:
Its curious the error staying at chat.postMessage.
@filmaj i solved!! :)
I just use the same token at the following parts:
Starting bot at the beggining of code:
Upload file (image) in slack cloud.
And for send file, i used the method below:
Glad you got it fixed!
FYI, we actually will be rolling back the new slack_file
property / feature of image blocks today due to various issues it caused for customers (including the problem you experienced earlier). So please continue using the image_url
property as I see you are doing in your last screenshot for the time being.
I will close this issue now but if you have further issues here, feel free to re-open or file a new issue.
Hi!
The same error is happening again.
To remember, the situation is that i am trying send image from slack cloud.
Me message with image is send using method say and block. The code is bellow:
Where infos[0] = "https://files.slack.com/files-pri/T01J6BY2VEU-F06EYTKJAJX/rentabilidades.png?pub_secret=bb2f7a0d27"
To complement, i used User Oauth Token to upload image.
I tried the following code:
And i got the answer:
This same code ran successfully about four hours earlier, but now it has this error.
Can anyone help me?