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

Slack integration uses a deprecated API #41890

Closed
zbodi74 opened this issue Apr 26, 2024 · 1 comment · Fixed by #41974
Closed

Slack integration uses a deprecated API #41890

zbodi74 opened this issue Apr 26, 2024 · 1 comment · Fixed by #41974
Assignees
Labels
.Escalation Notifications/Slack Priority:P1 Security holes w/o exploit, crashing, setup/upgrade, login, broken common features, correctness Reporting/Alerts .Team/BackendComponents also known as BEC Type:Bug Product defects
Milestone

Comments

@zbodi74
Copy link

zbodi74 commented Apr 26, 2024

Describe the bug

Slack integration uses a deprecated endpoint to upload files.

https://api.slack.com/changelog/2024-04-a-better-way-to-upload-files-is-here-to-stay

The original web API method for uploading files to Slack, files.upload, is being sunset on March 11, 2025. Beginning May 8, 2024, newly-created apps will be unable to use this API method.

Apps & integrations should migrate away from files.upload and instead leverage a combination of two APIs: files.getUploadURLExternal and files.completeUploadExternal. The use of these two methods is more reliable, especially when uploading large files.

To Reproduce

n/a

Expected behavior

Use the endpoints recommended instead of the deprecated one.

Logs

No response

Information about your Metabase installation

master

Severity

P1 - beginning May 8 it won't be possible to set up a new Slack integration

Additional context

(mu/defn upload-file!
"Calls Slack API `files.upload` endpoint and returns the URL of the uploaded file."
[file :- NonEmptyByteArray
filename :- ms/NonBlankString
channel-id :- ms/NonBlankString]
{:pre [(slack-configured?)]}
(let [request {:multipart [{:name "file", :content file}
{:name "filename", :content filename}
{:name "channels", :content channel-id}]}
response (try
(POST "files.upload" request)
(catch Throwable e
;; If file upload fails with a "not_in_channel" error, we join the channel and try again.
;; This is expected to happen the first time a Slack subscription is sent.
(if (= "not_in_channel" (:error-code (ex-data e)))
(do (-> channel-id
(maybe-lookup-id (slack-cached-channels-and-usernames))
join-channel!)
(POST "files.upload" request))
(throw e))))]
(u/prog1 (get-in response [:file :url_private])
(log/debug "Uploaded image" <>))))

@zbodi74 zbodi74 added Type:Bug Product defects Priority:P1 Security holes w/o exploit, crashing, setup/upgrade, login, broken common features, correctness Reporting/Alerts .Needs Triage and removed .Needs Triage labels Apr 26, 2024
@paoliniluis
Copy link
Contributor

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
.Escalation Notifications/Slack Priority:P1 Security holes w/o exploit, crashing, setup/upgrade, login, broken common features, correctness Reporting/Alerts .Team/BackendComponents also known as BEC Type:Bug Product defects
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants