slackapi / bolt-js

A framework to build Slack apps using JavaScript
https://tools.slack.dev/bolt-js/
MIT License
2.75k stars 393 forks source link

The 'value' property on ButtonAction is incorrectly typed #2133

Closed w33ble closed 4 months ago

w33ble commented 4 months ago

@slack/bolt version

3.18.0

Your App and Receiver Configuration

N/A

Node.js runtime version

v20.12.2

Steps to reproduce:

It's simple enough to prove that the value isn't always there...

  1. Create a bot with Interactivity
  2. Create an Interactivity webhook
  3. Post a message on Slack with an Button Block action that does not contain a value
  4. Click on that button
  5. Note that the body sent to the webhook has a payload where the object in actions does not contain a value

Example payload where actions array with no value in the object (truncated and unique identifiers changed):

{
  "type": "block_actions",
  // ...
  "actions": [
    {
      "action_id": "abc123",
      "block_id": "def456",
      "text": {
        "type": "plain_text",
        "text": "Hello World",
        "emoji": true
      },
      "type": "button",
      "action_ts": "1234567890.123456"
    }
  ]
}

Expected result:

The ButtonAction type should indicate that the value field is optional

Actual result:

The ButtonAction type indicates that the value field will always contain a string

See the type here.

Requirements

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. :bow:

Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you are agreeing to those rules.

srajiang commented 4 months ago

Good find @w33ble, and thanks for reporting this!

Looks like the documentation for Button block action payload is also consistent with value not being required. Got a fix here.

w33ble commented 4 months ago

@srajiang thanks for the quick fix! Looking forward to 3.19.0 being released. 👍🏾

zimeg commented 4 months ago

👋 Hey @w33ble! This fix should be available now with the latest v3.19.0 changes! 🚀