-
Notifications
You must be signed in to change notification settings - Fork 218
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
botMessage handler in Assistant middleware does not work when other event listeners do not exist #1414
Comments
Hi @rbioteau, thanks for asking the question. I've checked the code snippet using Socket Mode and I couldn't reproduce the NPE you've faced. One thing I am wonderfing is this error may be due to how you configure the Spring Boot app. As mentioned in this document page, bolt-java works properly only when using WebServiet + no additional request body parser in the Spring app: https://tools.slack.dev/java-slack-sdk/guides/supported-web-frameworks#spring-boot If your Spring Boot app already follows the above guidance, could you share the whole project (as minimal working example) and the stacktrace you've got when the NPE occurs? |
Thanks to take the time to have a look. Here is a minimal reproducer. I do not use Websocket, and the NPE is not logged (occurs in a FutureTask). |
… work when other event listeners do not exist
Thank you so much for reporting this issue. I just submitted a pull request #1415 resolving this issue. If the CI builds pass, I will release a patch version shortly. |
@rbioteau Thanks again for taking the time to report this issue and we're sorry for the disruption. The latest version 1.45.1 should resolve the issue for you! https://github.com/slackapi/java-slack-sdk/releases/tag/v1.45.1 |
When implementing the following example provided in the documentation an NPE prevent the proper execution of the use case.
In the above example we register a
botMessage
and auserMessage
on theAssistant
. However, when executing this simple app, these messages are never returned to my chat.The problem occurs in the
com.slack.api.bolt.util.EventsApiPayloadParser#buildEventPayload
method where myeventClass
isnull
. It seems to rely on a cache to retrieve a given Event class for an event name. The is cache is empty in my case and I need to explicitly callEventsApiPayloadParser.getEventTypeAndSubtype(MessageEvent.class)
in my code to initialize the map.Reproducible in:
The Slack SDK version
[INFO] +- com.slack.api:bolt-jakarta-servlet:jar:1.45.0:compile
[INFO] | +- com.slack.api:slack-api-model:jar:1.45.0:compile
[INFO] | +- com.slack.api:slack-api-client:jar:1.45.0:compile
[INFO] | +- com.slack.api:slack-app-backend:jar:1.45.0:compile
[INFO] | - com.slack.api:bolt:jar:1.45.0:compile
Java Runtime version
openjdk version "21.0.4" 2024-07-16 LTS
OpenJDK Runtime Environment Temurin-21.0.4+7 (build 21.0.4+7-LTS)
OpenJDK 64-Bit Server VM Temurin-21.0.4+7 (build 21.0.4+7-LTS, mixed mode, sharing)
OS info
Distributor ID: Ubuntu
Description: Ubuntu 24.04.1 LTS
Release: 24.04
Codename: noble
Steps to reproduce:
Run the springboot example with the code sample for Agent & Assistant from the documentation, See snippet above.
Expected result:
The botMessage handler should be executed.
Actual result:
The botMessage handler is not executed due to a NPE when retrieving the
botId
in theAssistant#apply
method.Requirements
Please make sure if this topic is specific to this SDK. For general questions/issues about Slack API platform or its server-side, could you submit questions at https://my.slack.com/help/requests/new instead. 🙇
Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you agree to those rules.
The text was updated successfully, but these errors were encountered: