slackapi / java-slack-sdk

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

Slash actions are working but block actions are not, due to "hashed timestamp blocks.actions not ok: dispatch_failed" #1189

Closed briankurilko closed 1 year ago

briankurilko commented 1 year ago

I have a slack app that displays a button with a block action after running a slash command. The slash command works, but the block action returns a 403. The request that the button push makes does not make it to my Java Spring Boot Bolt servlet, it receives a 403 without ever making a request to my Java application.

When running Slack from within the browser, I receive the following error in the network tab when I try to execute the slack action:

{"subtype":"missing_subtype","message":"hashed timestamp blocks.actions not ok: dispatch_failed","stack":"dispatch_failed: hashed timestamp blocks.actions not ok: dispatch_failed\n    at Bn._onNotOk (https://a.slack-edge.com/bv1-10/gantry-v2-shared.ecc6e6b.min.js?cacheKey=gantry-1690818443:1:179606)\n    at Bn.resolve (https://a.slack-edge.com/bv1-10/gantry-v2-shared.ecc6e6b.min.js?cacheKey=gantry-1690818443:1:179211)\n    at Bn._onLoad (https://a.slack-edge.com/bv1-10/gantry-v2-shared.ecc6e6b.min.js?cacheKey=gantry-1690818443:130:92498)"}

Does anyone know why this might be happening? Not sure if it matters, but I'm also running this app behind a corporate proxy (I've set up the correct http.proxyHost, http.proxyPort, and http.nonProxyHosts system properties to work with the proxy with the Bolt API, though).

The Slack SDK version

+--- com.slack.api:bolt-jakarta-servlet:1.30.0
|    +--- com.slack.api:slack-api-model:1.30.0
|    +--- com.slack.api:slack-api-client:1.30.0
|    |    +--- com.slack.api:slack-api-model:1.30.0 (*)
|    +--- com.slack.api:slack-app-backend:1.30.0
|    |    +--- com.slack.api:slack-api-model:1.30.0 (*)
|    |    +--- com.slack.api:slack-api-client:1.30.0 (*)
|    \--- com.slack.api:bolt:1.30.0
|         +--- com.slack.api:slack-api-model:1.30.0 (*)
|         +--- com.slack.api:slack-api-client:1.30.0 (*)
|         +--- com.slack.api:slack-app-backend:1.30.0 (*)
+--- com.slack.api:bolt-jakarta-jetty:1.30.0
|    +--- com.slack.api:slack-api-model:1.30.0 (*)
|    +--- com.slack.api:slack-api-client:1.30.0 (*)
|    +--- com.slack.api:slack-app-backend:1.30.0 (*)
|    +--- com.slack.api:bolt:1.30.0 (*)
|    +--- com.slack.api:bolt-jakarta-servlet:1.30.0 (*)
+--- com.slack.api:bolt-jakarta-servlet:1.30.0 (n)
+--- com.slack.api:bolt-jakarta-jetty:1.30.0 (n)

Java Runtime version

openjdk version "17.0.6" 2023-01-17 LTS

OS info

ProductName:            macOS
ProductVersion:         13.5
BuildVersion:           22G74
Darwin Kernel Version 22.6.0: Wed Jul  5 22:22:05 PDT 2023; root:xnu-8796.141.3~6/RELEASE_ARM64_T6000

Spring Boot versions:

 id 'org.springframework.boot' version '3.0.0'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'

Steps to reproduce:

Here's my code for building the view:

image

Here's my code for registering the button action:

image

And here's my code for the event handler itself:

image

Lastly, here is my servlet code, which should be the entrypoint of my project:

image

Expected result:

I expect the button to make a call to the block action I've configured in my Spring Boot backend and do the block action.

Actual result:

image

A call is never made to my Spring Boot backend (at least for the block action - the slash action works), and by looking at the network tab, the request fails with the following payload:

image

Does anyone have any ideas as to why this is happening?

seratch commented 1 year ago

Hi @briankurilko, could you double-check if you've configured Interactivity & Shortcuts section in the app configuration page (meaning https://api.slack.com/apps/{you app ID here}). You need to enable the interactivity and set a valid Request URL to handle interactive user action requests. The "dispatch_failed" error code indicates Slack API server does not know where to send a request.

briankurilko commented 1 year ago

Hi @seratch, the following is a screenshot of my Interactivity & Shortcuts page:

image

Also, here's what the configuration for the (working) slash command looks like:

image

As you can see, both the slash command and the interactivity and shortcuts request URL are the same (https://outpost.labs.ford.com/slack/events). I'm unsure why it works for slash commands, but does not for interactivity commands.

seratch commented 1 year ago

Here is a simple working example app for Spring Boot 3 users. Checking the difference in your app may be helpful to figure the cause out: https://github.com/slackapi/java-slack-sdk/tree/main/bolt-spring-boot-examples/spring-boot-3

briankurilko commented 1 year ago

@seratch one thing we tried was deploying our application to a separate server running on Pivotal Cloud Foundry instead of GCP - when we did this, all block actions worked. Similarly, when using ngrok to test our app, the block actions work as well. Could there be some kind of weird routing thing that Slack is trying to do when trying to connect to GCP application?

seratch commented 1 year ago

@briankurilko Some aspect in your GCP environment may prevent your app from properly receiving the request data, but I cannot guess anything so far. We are unable to help you out for GCP-specific questions. Please head to their communities or forum spaces. It seems that I don't have anything further I can do for you. Would you mind if I close this issue now?

briankurilko commented 1 year ago

@seratch Ok sure, you can close it.