slackapi / java-slack-sdk

Slack Developer Kit (including Bolt for Java) for any JVM language
https://slack.dev/java-slack-sdk/
MIT License
571 stars 212 forks source link

FilesUploadV2Request does not return an actionable response #1213

Closed matt-w-davis closed 10 months ago

matt-w-davis commented 11 months ago

When using the FilesUploadV2Request, encountering an error does not return the cause or any actionable information in the response or exception.

Reproducible in:

The Slack SDK version

[INFO] +- com.slack.api:bolt:jar:1.32.0:compile
[INFO] |  +- com.slack.api:slack-api-model:jar:1.32.0:compile
[INFO] |  +- com.slack.api:slack-app-backend:jar:1.32.0:compile
[INFO] +- com.slack.api:bolt-socket-mode:jar:1.32.0:compile
[INFO] +- com.slack.api:slack-api-client:jar:1.32.0:compile

Java Runtime version

openjdk version "17.0.6" 2023-01-17 LTS OpenJDK Runtime Environment Corretto-17.0.6.10.1 (build 17.0.6+10-LTS) OpenJDK 64-Bit Server VM Corretto-17.0.6.10.1 (build 17.0.6+10-LTS, mixed mode, sharing)

OS info

Amazon Linux 2

Steps to reproduce:

try {
    FilesUploadV2Request req = FilesUploadV2Request.builder().channel(thisChannel).content(body).initialComment(headline).build();
    FilesUploadV2Response res = null;
    res = slack.methods(botToken).filesUploadV2(req);
    if (!res.isOk()) {
        logger.error("Response: Ok: {} Error: {} Warning: {}", res.isOk(), res.getError(), res.getWarning());
    }
    Thread.sleep(1000);
} catch (Exception e) {
    logger.info("Error {}", e);
    run(parseProductToWxBotManagerQueue);
}

In the case of this error, the variable thisChannel was a channel that had been deleted.

Expected result:

Some actionable response or exception stating 'Channel ### not found' or similar

Actual result:

2023-09-26 00:25:37.936  INFO 11176 --- [task-1] gov.noaa.nws.wxbot.slack.WxBotManager    : Error {}

com.slack.api.methods.SlackFilesUploadV2Exception: null
        at com.slack.api.methods.impl.FilesUploadV2Helper.<init>(FilesUploadV2Helper.java:33) ~[slack-api-client-1.32.0.jar!/:1.32.0]
        at com.slack.api.methods.impl.MethodsClientImpl.filesUploadV2(MethodsClientImpl.java:2173) ~[slack-api-client-1.32.0.jar!/:1.32.0]
seratch commented 11 months ago

Hi @matt-w-davis, thanks for writing in.

I've confirmed the API client's behavior to be certain, but if the specified channel does not exist, the filesUploadV2 method threw an exception with ample information for me. Could you reassess if the channel ID is causing your unexpected situation? Also, if the channel is still active, your file uploading operation may have been successful, which could explain why you didn't encounter any errors in this scenario.

I hope you'll figure the cause out soon!

github-actions[bot] commented 10 months ago

👋 It looks like this issue has been open for 30 days with no activity. We'll mark this as stale for now, and wait 10 days for an update or for further comment before closing this issue out. If you think this issue needs to be prioritized, please comment to get the thread going again! Maintainers also review issues marked as stale on a regular basis and comment or adjust status if the issue needs to be reprioritized.

github-actions[bot] commented 10 months ago

As this issue has been inactive for more than one month, we will be closing it. Thank you to all the participants! If you would like to raise a related issue, please create a new issue which includes your specific details and references this issue number.

DaanA32 commented 9 months ago

Hi,

I have the same issue:

[WARN ] 2023-11-30 15:47:37.150 [Worker-1] SlackAlertor - Catching
com.slack.api.methods.SlackFilesUploadV2Exception: null
        at com.slack.api.methods.impl.FilesUploadV2Helper.<init>(FilesUploadV2Helper.java:30)

Dependencies:

    <dependency>
        <groupId>com.slack.api</groupId>
        <artifactId>slack-api-client</artifactId>
        <version>1.36.1</version>
    </dependency>
    <dependency>
        <groupId>com.squareup.okhttp3</groupId>
        <artifactId>okhttp</artifactId>
        <version>4.12.0</version>
    </dependency>
DaanA32 commented 4 months ago

It's the same issue as: https://github.com/slackapi/python-slack-sdk/issues/1326 You have to use channel id instead of name, but this is not clear from the error message!