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

Handle private channels/improve channel info error handling and logging #5

Open
2 tasks
mbland opened this issue Nov 23, 2016 · 0 comments
Open
2 tasks
Assignees

Comments

@mbland
Copy link
Owner

mbland commented Nov 23, 2016

While figuring out why https://github.com/mbland/hubot-slack-github-issues wasn't working for @geekdave, after some back-and-forth on 18F#51, we figured out it was because he was trying to use it in a private Slack channel.

What happened was that the channel ID was not in the Slack RTM client's channel cache, so SlackRtmDataStore.channelById was returning null. Impl.processMessage from lib/reaction-issue-filer.js wasn't expecting or handling this, hence the error.

After reviewing https://api.slack.com/rtm#channel_selection and https://api.slack.com/methods/rtm.start, it appears the solution may be a matter of trying to look in the groups and mpims caches for incoming channel IDs starting with G and the ims cache for IDs starting with D. (Note that, per the Slack rtm.start doc, "MPIMs are only returned to the client if mpim_aware is set when calling rtm.start.")

Reproducible in:

hubot-slack-github-issues version: git+https://git@github.com/mbland/hubot-slack-github-issues.git
OS version(s): any
Device(s): any

Steps to reproduce:

  1. Add git+https://git@github.com/mbland/hubot-slack-github-issues.git to your Hubot instance.
  2. Per the https://github.com/mbland/hubot-slack-github-issues README, add config/slack-github-issues.json to your Hubot instance. Use the default all-channel emoji from the mbland/hubot-slack-github-issues repo or configure your own.
  3. Set the following environment variables:
    HUBOT_SLACK_TOKEN="<your Hubot's Slack API token>"
    HUBOT_GITHUB_TOKEN="<a GitHub token for your Hubot user>"
    HUBOT_LOG_LEVEL="debug"
  4. Launch your Hubot instance.
  5. In Slack, post a message to a private channel/group or direct message session.
  6. Add the emoji configured in step 1 to the message.

Expected result:

As with normal Slack channels, the plugin should react to the reaction_added event, file a GitHub issue, and respond to the user who added the reaction with the URL of the newly-created issue.

Actual result:

Hubot reacts to the event, but responds to the user with Cannot read property 'name' of undefined. The logs show a listener executed for Message [Object object] followed by DEBUG messages containing Sending to G... followed by Cannot read property 'name' of undefined. See @geekdave's screenshot from 18F#51, also attached below, for a concrete example.

Note that I'm working separately on making the error handling and logging more robust, regardless of upstream changes to hubot-slack.

Attachments:

Actions:

  • guard against the channel info coming back as undefined to the extent possible, i.e. figure out how to handle messages from private channels if possible
  • produce a better error response if it still does come back undefined
@mbland mbland self-assigned this Nov 23, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant