-
Notifications
You must be signed in to change notification settings - Fork 663
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
interactive-messages: message_action payload routed to viewSubmission handler #929
Comments
Hey @davidalpert, Interesting observation. I'm not sure this is really a bug. The documentation states that callback IDs should be unique. I do see how you made the assumptions you did though. I also see your suggestion of using the registration method type to determine the correct handler, but that would also require us having to analyze the handlers to determine which one is correct. IMO it adds too much overhead. Bolt did recently add type as a constraint option. We could looking at doing something similar here. |
thank you for considering it. now that I've learned a bit more about both the slack app callbacks and the @slack/interactive-messages package I don't think I will stumble over this anymore. I was simply surprised that a viewSubmission-registered handler would match a callback of type other than I am comfortable closing this if you feel that is expected behavior. |
Sounds good @davidalpert. I'll mark it as closed but feel free to reopen if you feel more discussion is needed for this. |
Hey folks, just wanted to add my 2c 👋 Slack doesn’t enforce unique Instead I think this issue highlights a shortcoming of our constraints matching system’s idea of “best” when finding the right handler. The way it works is that we look at each handler (in the order they are added) and evaluate whether there’s any reason to eliminate it from matching a certain payload. If there is, move onto the next handler. If there isn’t, that means this handler satisfies the constraints and we can invoke it. Notice how we’re not gathering all listeners which weren’t eliminated to do a second pass to determine which listener matches the most. That we be more expensive. Instead, we provide you this guidance so we don’t have to make the performance tradeoff: register your most specific handlers first and your more generic handlers later. In the case you described above, you happen to know the
Now, I’m going to read between the lines of your original message and assume you didn’t do this because you’re reading from a directory in while each file exports a handler and constraints, and you’re looking to use the most generic method possible to register those handlers. If that’s the case, I think we can make a change to better suit your needs. We could add a new possible value for the
Would this change be something you’re interested in? |
We are closing this issue as At this time, we recommend migrating to Bolt for JavaScript, a framework that offers all of the functionality available in this package (and more!). To help with that process, we've also provided some migration samples for those looking to convert their existing apps. |
Description
While first working with the
@slack/interactive-messages
library and the new Slack App patterns I misunderstood the role of thecallback_id
. Now I understandcallback_id
as a way to uniquely identify which workflow step is sending a given callback to easily route the callbacks to the correct handlers. Originally, however, I thought that thecallback_id
was used to tie together several steps in a workflow so was using the samecallback_id
value for both message actions and view submissions.Given that there are registration handlers for different types of callback payloads I was surprised when a handler I had registered through the
viewSubmission(...)
method started interceptingmessage_action
payloads.e.g.
action(...)
registration method implies a"type": "message_action"
constraint;viewSubmission(...)
registration method implies a"type": "view_submission"
constraint;but these implied constraints don't seem to get applied.
What type of issue is this? (place an
x
in one of the[ ]
)Requirements (place an
x
in each of the[ ]
)Bug Report
Filling out the following details about bugs will help us solve your issue sooner.
Packages:
Select all that apply:
@slack/web-api
@slack/events-api
@slack/interactive-messages
@slack/rtm-api
@slack/webhooks
Reproducible in:
package version:
@slack/interactive-messages@1.4.0
node version:
v10.16.0
OS version(s):
Steps to reproduce:
create a slack app and configure a message interaction to send an
order_pizza
callback idcreate an api using
@slack/interactive-messages@1.4.0
to handle callbacks from this slack appregister a
message_action
handler using theaction(...)
return a view payload to open a modal view with the view
callback_id
set toorder_pizza
(because it's part of the same workflow)initiate the action in the slack app
verify that the "Pizza Options" modal dialog opens
add a new handler before the action handler (because sometimes scanning folders for files reads and registers
dialogHandlers.js
beforemessageHandlers.js
)initiate the action in the slack app
Expected result:
openPizzaOptionsModal
handler fires, opening the "Pizza Options" dialogpizzaOrderSubmitted
handler firesActual result:
pizzaOrderSubmitted
handler fires on the initialmessage_action
, throws an error because it expects the payload to match theview_submission
schemaThe text was updated successfully, but these errors were encountered: