Skip to content
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

SlackAction typedef incorrectly defines channel as required #341

Closed
4 of 9 tasks
bwoskow-ld opened this issue Dec 13, 2019 · 3 comments
Closed
4 of 9 tasks

SlackAction typedef incorrectly defines channel as required #341

bwoskow-ld opened this issue Dec 13, 2019 · 3 comments
Assignees
Labels
bug M-T: confirmed bug report. Issues are confirmed when the reproduction steps are documented TypeScript-specific

Comments

@bwoskow-ld
Copy link

Description

Per the typedefs, SlackAction should have a non-nullable channel object yet it is undefined.

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • testing related
  • discussion

Requirements (place an x in each of the [ ])

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Bug Report

SlackAction (defined as one of BlockAction, InteractiveMessage, DialogSubmitAction, or MessageAction) is consistently defined as having a non-nullable channel object. However, when accessing action.channel.id in any of my interaction handlers, I have the following error:

Cannot read property 'id' of undefined

Either the type defs are wrong or channel isn't getting set as it should be.

Reproducible in:

package version: Bolt 1.4.1

node version: 12.4.0

OS version(s): macOS Mojave 10.14.3

Steps to reproduce:

  1. Set up a button with an action_id of button_click.
  2. Add an action handler as follows:
  bolt.action(
    'button_click',
    async ({ack, action}) => {
      ack();
      console.log(action.channel.id);
    }
  );
  1. Click the button.

Expected result:

A console log of the channel id.

Actual result:

A console log of a stacktrace:

node_1      | [2019-12-13T19:13:02.179Z]  INFO: Slack/300 on 132c003815da: Incoming request... (correlationId=<redacted>, slack_user_id=<redacted>, team_id=<redacted>, action=button_click)
node_1      | (node:300) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'id' of undefined
node_1      |     at bolt.action (/usr/src/app/src/interactions/index.js:37:34)
node_1      |     at next (/usr/src/app/node_modules/@slack/bolt/src/middleware/process.ts:36:7)
node_1      |     at /usr/src/app/node_modules/@slack/bolt/src/middleware/builtin.ts:178:5
node_1      |     at next (/usr/src/app/node_modules/@slack/bolt/src/middleware/process.ts:36:7)
node_1      |     at exports.onlyActions (/usr/src/app/node_modules/@slack/bolt/src/middleware/builtin.ts:35:3)
node_1      |     at Object.processMiddleware (/usr/src/app/node_modules/@slack/bolt/src/middleware/process.ts:78:3)
node_1      |     at listeners.forEach (/usr/src/app/node_modules/@slack/bolt/src/App.ts:480:11)
node_1      |     at Array.forEach (<anonymous>)
node_1      |     at process_1.processMiddleware (/usr/src/app/node_modules/@slack/bolt/src/App.ts:478:24)
node_1      |     at next (/usr/src/app/node_modules/@slack/bolt/src/middleware/process.ts:68:7)
node_1      |     at process._tickCallback (internal/process/next_tick.js:61:11)
node_1      | (node:300) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
node_1      | (node:300) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Attachments:

None

@seratch seratch added the bug M-T: confirmed bug report. Issues are confirmed when the reproduction steps are documented label Dec 15, 2019
@seratch
Copy link
Member

seratch commented Dec 15, 2019

Thanks for flagging this. You're right. The channel object is always undefined for the cases a button is available in modals and Home tab, unlike in messages. I'll make a pull request to fix this.

@bwoskow-ld
Copy link
Author

Thanks for taking a look @seratch, and also for the prompt reply. I subscribed to notifications on your PR and will follow along there.

seratch added a commit that referenced this issue Dec 16, 2019
 Fix #341 - Make channel file in block_actions payload optional (+ add view field)
@seratch
Copy link
Member

seratch commented Dec 16, 2019

@bwoskow-ld Thanks for your feedback! The PR has been merged. 🎉 The change will be included in the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug M-T: confirmed bug report. Issues are confirmed when the reproduction steps are documented TypeScript-specific
Projects
None yet
Development

No branches or pull requests

2 participants