What happened
When you try to use UploadFileV2 or UploadFileV2Context, the error's aren't wrapped which results in a suboptimal debugging experience.
If any of the internal slack API call's fail the errors are bubbling up without a wrap so you have no idea which call failed.
Since neither does UploadToURL wrapped or parsed correctly the only error you get if you submit the wrong file size for the file (which is a mandatory param): slack server error: 500 Internal Server Error, in that case your only hope would be to enable debug mode, however it yields this:
slack-go/slack2025/11/08 11:56:53 misc.go:366: HTTP/2.0 500 Internal Server Error
Content-Length: 25
Alt-Svc: h3=":443"; ma=86400
Content-Type: text/plain
Cross-Origin-Resource-Policy: cross-origin
Date: Sat, 08 Nov 2025 10:56:53 GMT
Server: envoy
Timing-Allow-Origin: *
Via: envoy-edge-fra-bqmexryl, 1.1 eb8dd67e239abea324e36244f60eec4c.cloudfront.net (CloudFront)
X-Amz-Cf-Id: oMPqjmbMV3IVFk62PXtdHBkGZ9_rJ_cIeTOGJndMHwXyVyZ0cENrVA==
X-Amz-Cf-Pop: FRA60-P9
X-Backend: miata-prod-fra-v2-5fb4968c7b-dwl5c
X-Cache: Error from cloudfront
X-Envoy-Upstream-Service-Time: 2146
X-Slack-Edge-Shared-Secret-Outcome: shared-secret
internal error: s3_upload
In this case since the URL and the method name is still missing you still have 3 context which of the 3 steps failed.
(I know the error in the upstream API is also incorrect on the slack side, throwing internal error: s3_upload with 500 status code for a wrong from parameter is more then misleading however I don't think we can fix this in the library level.)
Expected behavior
Errors in UploadFileV2Context are wrapped with the actual step/function that failed, for example: UploadToURL error: slack server error: 500 Internal Server Error.
An upgrade to this would be to return the actual message body in the errors, for this we have to modify the internal errors of checkStatusCode which is used by postWithMultipartResponse, postLocalWithMultipartResponse and postWithMultipartResponse so they include the response body.
An ideal error imho would look like this: UploadToURL error: slack server error: status: 500, body: internal error: s3_upload.
Steps to reproduce
Call a file upload with the v2 API with the wrong file size.
reproducible code
_, err = s.client.UploadFileV2(slack.UploadFileV2Parameters{
Reader: randomBuffer,
Filename: fileName,
Title: fileName,
InitialComment: "reproduce message",
Channel: channelID,
ThreadTimestamp: threadTS,
FileSize: 2, // This is just a random number so we can easily reproduce it
})
if err != nil {
logger.Error("failed to upload file to thread", "error", err)
}
or the exact code that i've faced the issue with: https://github.com/Shikachuu/wap-bot/blob/main/internal/messageprocessor/slack.go#L97
manifest.yaml
https://github.com/Shikachuu/wap-bot/blob/main/deploy/slack-app.yaml
Versions
- Go:
1.25.3
- slack-go/slack:
v0.17.3
PS: with a maintainer's approval I'm more then happy to submit a PR for this
What happened
When you try to use
UploadFileV2orUploadFileV2Context, the error's aren't wrapped which results in a suboptimal debugging experience.If any of the internal slack API call's fail the errors are bubbling up without a wrap so you have no idea which call failed.
Since neither does
UploadToURLwrapped or parsed correctly the only error you get if you submit the wrong file size for the file (which is a mandatory param):slack server error: 500 Internal Server Error, in that case your only hope would be to enable debug mode, however it yields this:In this case since the URL and the method name is still missing you still have 3 context which of the 3 steps failed.
(I know the error in the upstream API is also incorrect on the slack side, throwing
internal error: s3_uploadwith 500 status code for a wrong from parameter is more then misleading however I don't think we can fix this in the library level.)Expected behavior
Errors in
UploadFileV2Contextare wrapped with the actual step/function that failed, for example:UploadToURL error: slack server error: 500 Internal Server Error.An upgrade to this would be to return the actual message body in the errors, for this we have to modify the internal errors of
checkStatusCodewhich is used bypostWithMultipartResponse,postLocalWithMultipartResponseandpostWithMultipartResponseso they include the response body.An ideal error imho would look like this:
UploadToURL error: slack server error: status: 500, body: internal error: s3_upload.Steps to reproduce
Call a file upload with the v2 API with the wrong file size.
reproducible code
or the exact code that i've faced the issue with: https://github.com/Shikachuu/wap-bot/blob/main/internal/messageprocessor/slack.go#L97
manifest.yaml
https://github.com/Shikachuu/wap-bot/blob/main/deploy/slack-app.yaml
Versions
1.25.3v0.17.3PS: with a maintainer's approval I'm more then happy to submit a PR for this