Fail to run event listeners for app_mention events with bot_message subtype
Allist opened this issue · comments
Reproducible in:
The Slack SDK version
1.29.2
Java Runtime version
openjdk version "17.0.9" 2023-10-17 LTS
OpenJDK Runtime Environment Zulu17.46+19-CA (build 17.0.9+8-LTS)
OpenJDK 64-Bit Server VM Zulu17.46+19-CA (build 17.0.9+8-LTS, mixed mode, sharing)
OS info
Steps to reproduce:
- assign handler about AppMentionEvent to slack app.
App.event(AppMentionEvent.class, this.appMentionEventHandler);
- using workflow, mention bot.
- Then bot returns below warn logs.
2024-01-30 11:36:13.783 WARN 116277 --- [socket-mode-message-processor-worker-71] com.slack.api.bolt.App : No BoltEventHandler registered for event: app_mention:bot_message
---
[Suggestion] You can handle this type of event with the following listener function:
app.event(AppMentionBotEvent.class, (payload, ctx) -> {
return ctx.ack();
});
2024-01-30 11:36:13.783 WARN 116277 --- [socket-mode-message-processor-worker-71] c.s.api.bolt.socket_mode.SocketModeApp : Unsuccessful Bolt app execution (status: 404, body: {"error":"no handler found"})
Expected result:
Expected java-slack-sdk has AppMentionBotEvent.class
. but doesn't.
Actual result:
Curious I need to create my own AppMentionBotEvent.class
or you plan to support it.
Because above log suggested to me to use AppMentionBotEvent.class
.
Requirements
I can confirm this issue. I have an app_mention event handler defined in my Bolt for Java app. When a user app-mentions my bot, the app_mention handler executes as expected. However, when I built a workflow to at-mention my bot, the following logs show up:
[socket-mode-message-processor-worker-32] WARN com.slack.api.bolt.App - No BoltEventHandler registered for event: app_mention:bot_message
---
[Suggestion] You can handle this type of event with the following listener function:
app.event(AppMentionBotEvent.class, (payload, ctx) -> {
return ctx.ack();
});
[socket-mode-message-processor-worker-32] DEBUG com.slack.api.bolt.App - The handler completed (request type: Event)
[socket-mode-message-processor-worker-32] WARN com.slack.api.bolt.socket_mode.SocketModeApp - Unsuccessful Bolt app execution (status: 404, body: {"error":"no handler found"})
I think the underlying cause of the issue is that ONLY in the case that a non-human creates the app mention event, the event contains a subtype
- which surprised me (I thought only message events contain those, which is what is described in our docs). I tested this scenario out (a workflow that at-mentions a Bolt app) and the type
of such an event is app_mention
and the subtype
is bot_message
. A human app-mention event has no subtype
.
The suggestion you saw in the logs comes from this area of the code. This, in turn, assembles the specific event class Bolt suggests to listen for using the toEventClassName
.
I think this is a bug, but it is unclear to me whether this is a bug in the above toEventClassName
only or something deeper. Specifically, I would expect a registered app-mention handler to be able to handle BOTH human and non-human app mentions. In fact, this is the case in Bolt for JS. Another thing to consider when evaluating this is that there are no app_mention event subtypes that apps on the api.slack.com/apps page can register to; there is only one event.
@seratch what is your opinion here? Do you agree with my assessment?