Skip to content
This repository has been archived by the owner on Dec 8, 2017. It is now read-only.

[Question] Still necessary to use a fork? #51

Closed
geekdave opened this issue Nov 23, 2016 · 22 comments · Fixed by #54
Closed

[Question] Still necessary to use a fork? #51

geekdave opened this issue Nov 23, 2016 · 22 comments · Fixed by #54

Comments

@geekdave
Copy link

Regarding:

Note: This plugin depends upon 18F/hubot-adapter-slack-bot#3.4.2-handle-reaction-added, which in turn depends upon 18F/node-slack-client#1.5.0-handle-reaction-added. These packages are custom forks of the hubot-slack and slack-client packages that have had support for the reaction_added event patched in. When those official packages have been updated to include reaction_added support, this plugin will be updated to use those packages instead of the custom versions.

I notice that reaction support seems to be merged into hubot-slack: slackapi/hubot-slack#360

Is it still necessary for this project to use a fork of hubot-slack?

@mbland
Copy link
Contributor

mbland commented Nov 23, 2016

@geekdave My personal fork, https://github.com/mbland/hubot-slack-github-issues, depends on the latest official https://github.com/slackhq/hubot-slack. You can depend on that fork in the very short-term, or wait until I rebrand and repackage it as mbland/slack-github-issues, which I may get to even today. (Code's been done for a while; I've been obsessing over a packaging detail.)

@geekdave
Copy link
Author

Thanks for the tip, @mbland !

Here's the relevant snippet of my bot's package.json where I added your fork:

    "hubot-slack": "^4.2.2",
    "hubot-slack-github-issues": "git+https://git@github.com/mbland/hubot-slack-github-issues.git",

I created a github bot user account and generated a token, then set it as follows:

heroku config:set HUBOT_GITHUB_TOKEN=xxxxxxxxxx

My test repo is http://github.com/TestArmada/discuss, so I set up the following config:

{
  "githubUser": "TestArmada",
  "githubTimeout": 5000,
  "slackTimeout": 5000,
  "successReaction": "heavy_check_mark",
  "rules": [
    {
      "reactionName": "evergreen_tree",
      "githubRepository": "discuss"
    }
  ]
}

After pushing and deploying, and adding the evergreen tree emoji I see this in my Heroku logs. Any idea where I may have gone wrong?

2016-11-23T16:59:33.120480+00:00 app[web.1]: [Wed Nov 23 2016 16:59:33 GMT+0000 (UTC)] ERROR ReferenceError: Promise is not defined
2016-11-23T16:59:33.120493+00:00 app[web.1]:   at ReactionIssueFiler.execute (/app/node_modules/hubot-slack-github-issues/lib/reaction-issue-filer.js:30:14)
2016-11-23T16:59:33.120494+00:00 app[web.1]:   at fileIssue (/app/node_modules/hubot-slack-github-issues/scripts/slack-github-issues.js:39:16)
2016-11-23T16:59:33.120495+00:00 app[web.1]:   at Listener.listener (/app/node_modules/hubot-slack-github-issues/scripts/slack-github-issues.js:56:16)
2016-11-23T16:59:33.120495+00:00 app[web.1]:   at executeListener (/app/node_modules/hubot/src/listener.coffee:65:11, <js>:53:19)
2016-11-23T16:59:33.120496+00:00 app[web.1]:   at allDone (/app/node_modules/hubot/src/middleware.coffee:44:37, <js>:34:16)
2016-11-23T16:59:33.120497+00:00 app[web.1]:   at /app/node_modules/hubot/node_modules/async/lib/async.js:274:13
2016-11-23T16:59:33.120498+00:00 app[web.1]:   at Object.async.eachSeries (/app/node_modules/hubot/node_modules/async/lib/async.js:142:20)
2016-11-23T16:59:33.120498+00:00 app[web.1]:   at Object.async.reduce (/app/node_modules/hubot/node_modules/async/lib/async.js:268:15)
2016-11-23T16:59:33.120499+00:00 app[web.1]:   at /app/node_modules/hubot/src/middleware.coffee:49:7, <js>:37:22
2016-11-23T16:59:33.120500+00:00 app[web.1]:   at process._tickCallback (node.js:458:13)
2016-11-23T16:59:33.120501+00:00 app[web.1]: 

@mbland
Copy link
Contributor

mbland commented Nov 23, 2016

What version of Node are you using? Promise was added in 0.12.something-or-other.

@geekdave
Copy link
Author

Wow, good catch. Looks like the slack hubot yeoman generator pinned my bot to 0.10! I updated it to 6.x and now I'm getting a different error:

2016-11-23T17:11:03.205488+00:00 app[web.1]: (node:4) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): TypeError: Cannot read property 'name' of undefined

And the bot responds:

Captain HookBOT	[10:11 AM]  
@dave: Cannot read property 'name' of undefined

@mbland
Copy link
Contributor

mbland commented Nov 23, 2016

I have no idea where that is coming from. Do you have a repo to share, and more of the log file?

@geekdave
Copy link
Author

Sure! Here's the repo:

https://github.com/TestArmada/captainhook

And here's the full log:

2016-11-23T17:45:40.957240+00:00 heroku[web.1]: Starting process with command `bin/hubot -a slack`
2016-11-23T17:45:47.020933+00:00 heroku[web.1]: State changed from starting to up
2016-11-23T17:45:47.108023+00:00 app[web.1]: [Wed Nov 23 2016 17:45:47 GMT+0000 (UTC)] INFO Logged in as captainhook of TestArmada
2016-11-23T17:45:47.145683+00:00 app[web.1]: [Wed Nov 23 2016 17:45:47 GMT+0000 (UTC)] INFO Slack client now connected
2016-11-23T17:45:47.150609+00:00 app[web.1]: [Wed Nov 23 2016 17:45:47 GMT+0000 (UTC)] WARNING Loading scripts from hubot-scripts.json is deprecated and will be removed in 3.0 (https://github.com/github/hubot-scripts/issues/1113) in favor of packages for each script.
2016-11-23T17:45:47.150611+00:00 app[web.1]: 
2016-11-23T17:45:47.150612+00:00 app[web.1]: Your hubot-scripts.json is empty, so you just need to remove it.
2016-11-23T17:45:47.336825+00:00 app[web.1]: [Wed Nov 23 2016 17:45:47 GMT+0000 (UTC)] INFO hubot-slack-github-issues: reading configuration from config/slack-github-issues.json
2016-11-23T17:45:47.335477+00:00 app[web.1]: [Wed Nov 23 2016 17:45:47 GMT+0000 (UTC)] INFO hubot-slack-github-issues: loading
2016-11-23T17:45:47.340425+00:00 app[web.1]: [Wed Nov 23 2016 17:45:47 GMT+0000 (UTC)] INFO hubot-slack-github-issues: listening for reaction_added events
2016-11-23T17:45:47.661043+00:00 app[web.1]: [Wed Nov 23 2016 17:45:47 GMT+0000 (UTC)] INFO hubot-redis-brain: Using default redis on localhost:6379
2016-11-23T17:45:53.656954+00:00 app[web.1]: (node:4) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): TypeError: Cannot read property 'name' of undefined

@mbland
Copy link
Contributor

mbland commented Nov 23, 2016

Are you actually not able to file issues? It works on my machine... 😏

Does that UnhandledPromiseRejectionWarning happen when you actually try adding an emoji to trigger a GitHub issue? Because the INFO hubot-slack-github-issues: listening for reaction_added events line indicates that the plugin has at least loaded successfully.

If you haven't tried to file an issue yet, it could well be another plugin that's causing the error. You could try pulling things out of external-scripts.json to see if the message still happens or not. (Obviously try pulling hubot-slack-github-issues out first.)

I cloned your repo, updated the config for my user/repo, and ran it locally (not on Heroku) with my credentials under Node v6.2.1, and sure enough got it to work (after a first attempt pointed out that I hadn't enabled issues on my repo yet):

captainhook

The log from the above (where I've redacted the message ID as [msgid]):

> captainhook@0.0.0 hubot /Users/msb/src/tmp/captainhook
> hubot --adapter slack

[Wed Nov 23 2016 13:47:52 GMT-0500 (EST)] INFO Logged in as reaction-example-bot of mbland
[Wed Nov 23 2016 13:47:53 GMT-0500 (EST)] INFO Slack client now connected
[Wed Nov 23 2016 13:47:53 GMT-0500 (EST)] WARNING Loading scripts from hubot-scripts.json is deprecated and will be removed in 3.0 (https://github.com/github/hubot-scripts/issues/1113) in favor of packages for each script.

Your hubot-scripts.json is empty, so you just need to remove it.
[Wed Nov 23 2016 13:47:53 GMT-0500 (EST)] INFO hubot-slack-github-issues: loading
[Wed Nov 23 2016 13:47:53 GMT-0500 (EST)] INFO hubot-slack-github-issues: reading configuration from config/slack-github-issues.json
[Wed Nov 23 2016 13:47:53 GMT-0500 (EST)] INFO hubot-slack-github-issues: listening for reaction_added events
[Wed Nov 23 2016 13:47:53 GMT-0500 (EST)] ERROR hubot-heroku-alive included, but missing HUBOT_HEROKU_KEEPALIVE_URL. `heroku config:set HUBOT_HEROKU_KEEPALIVE_URL=$(heroku apps:info -s  | grep web-url | cut -d= -f2)`
[Wed Nov 23 2016 13:47:54 GMT-0500 (EST)] INFO hubot-redis-brain: Using default redis on localhost:6379
[Wed Nov 23 2016 13:47:54 GMT-0500 (EST)] ERROR hubot-heroku-alive included, but missing HUBOT_HEROKU_KEEPALIVE_URL. `heroku config:set HUBOT_HEROKU_KEEPALIVE_URL=$(heroku apps:info -s  | grep web-url | cut -d= -f2)`
[Wed Nov 23 2016 13:48:09 GMT-0500 (EST)] INFO hubot-slack-github-issues: [msgid]: processing: https://mbland.slack.com/archives/general/[msgid]
[Wed Nov 23 2016 13:48:09 GMT-0500 (EST)] INFO hubot-slack-github-issues: [msgid]: matches rule: reactionName: evergreen_tree, githubRepository: hubot-slack-github-issues
[Wed Nov 23 2016 13:48:09 GMT-0500 (EST)] INFO hubot-slack-github-issues: [msgid]: getting reactions
[Wed Nov 23 2016 13:48:10 GMT-0500 (EST)] INFO hubot-slack-github-issues: [msgid]: filing GitHub issue in mbland/hubot-slack-github-issues
[Wed Nov 23 2016 13:48:12 GMT-0500 (EST)] ERROR hubot-slack-github-issues: [msgid]: failed to create a GitHub issue: received 410 response from GitHub API: {"message":"Issues are disabled for this repo","documentation_url":"https://developer.github.com/v3/issues/"}
[Wed Nov 23 2016 13:50:09 GMT-0500 (EST)] INFO hubot-slack-github-issues: [msgid]: processing: https://mbland.slack.com/archives/general/p1479926788000002
[Wed Nov 23 2016 13:50:09 GMT-0500 (EST)] INFO hubot-slack-github-issues: [msgid]: matches rule: reactionName: evergreen_tree, githubRepository: hubot-slack-github-issues
[Wed Nov 23 2016 13:50:09 GMT-0500 (EST)] INFO hubot-slack-github-issues: [msgid]: getting reactions
[Wed Nov 23 2016 13:50:10 GMT-0500 (EST)] INFO hubot-slack-github-issues: [msgid]: filing GitHub issue in mbland/hubot-slack-github-issues
[Wed Nov 23 2016 13:50:11 GMT-0500 (EST)] INFO hubot-slack-github-issues: [msgid]: adding heavy_check_mark
[Wed Nov 23 2016 13:50:12 GMT-0500 (EST)] INFO hubot-slack-github-issues: [msgid]: created: https://github.com/mbland/hubot-slack-github-issues/issues/2

The UnhandledPromiseRejectionWarning error was apparently added in v6.6.0; specifically it was added by nodejs/node#8223. I updated to Node v6.9.1 and tried it again, with success and no UnhandledPromiseRejectionWarning.

Believe it or not, I've never messed with Heroku (yet), so if the problem is there, I'd have to do some more digging to help you.

@geekdave
Copy link
Author

Weird! I ran it locally and got the same issue. I wonder if I've set up a token wrong or something? I'll keep working on it. Really appreciate you taking a look!

@mbland
Copy link
Contributor

mbland commented Nov 23, 2016

I'm curious, though: Did you try tagging a message with an emoji (presuming the 🌲)? So it's running, but the issue isn't getting filed and you're seeing that error?

Or are you seeing the error without tagging a message? If you do then tag a message, what happens?

I'm asking because based on when you said earlier that "And the bot responds:", I'm not clear if that meant you actually tried tagging a message yet or not.

@geekdave
Copy link
Author

Yep, the error is only at the point of adding the evergreen emoji. Here are the logs with hubot verbose logging:

captainhook_ dcadwal_atreyu zsh _152x56

@mbland
Copy link
Contributor

mbland commented Nov 23, 2016

I swear, that looks like you're getting an older version of hubot-slack somehow, because hubot can't find a matching listener for the message type. But then, the updated hubot-slack-github-issues plugin shouldn't be working, either, because it depends on hubot.react being present.

Either way it really seems like something's out of sync. Any chance you can do a fresh npm install or just start from a fresh clone and see what happens?

@geekdave
Copy link
Author

Same result with a fresh clone, with npm cache clean beforehand.

When I npm install I see I'm getting hubot-slack@4.2.2 - the README says This plugin depends on ... hubot-slack v4.10.0 or higher. But I don't see that version available on npm. 4.2.2 seems to be the latest. Is that expected?

@mbland
Copy link
Contributor

mbland commented Nov 23, 2016

Whoops, I just need to update the README. ☹️ The package.json doesn't lie, though.

OK, just re-ran with HUBOT_LOG_LEVEL=debug, and I do see the falling back to catch-all and Executing listener callback for Message '[object Object]' lines, but then it proceeds as advertised and files an issue. The Sending to [channelId] <@[userId]> bits show up after successfully filing an issue.

Still looking, though I gotta run soon... The first message you should see from the plugin is processing: https://[room].slack.com/..., so I'm starting to look in that vicinity.

@mbland
Copy link
Contributor

mbland commented Nov 23, 2016

Oh, I think I just realized something...somehow hubot or hubot-slack isn't passing along the Channel object, which means this line is working with an undefined value: https://github.com/mbland/hubot-slack-github-issues/blob/master/lib/reaction-issue-filer.js#L89

Is there anything special about the channel you're tagging a message in? Have you invited your Hubot to join it (though I guess it wouldn't reply if it wasn't)? What if you did it from #general, if you're not already?

I guess what I'm saying is, there may be a feature of your actual Slack channel that's different from mine. And I may need to add a new condition, test case, and a little bit of logging based on what we find out.

@geekdave
Copy link
Author

geekdave commented Nov 23, 2016

🎉 🎉 🎉 YES!!! 🎉 🎉 🎉

That was the issue. The tagging was happening inside a private channel (of which the bot was a member). When I switched to a public channel, it worked like a charm.

Thanks so much for helping to debug.

@mbland
Copy link
Contributor

mbland commented Nov 23, 2016

Hmm, OK. Good to know. Going to open an issue in my fork and address it there.

Oh, and woo-hoo! 🎉 Glad I could get you moving. 😃

mbland added a commit to mbland/hubot-slack-github-issues that referenced this issue Dec 1, 2016
As discovered in 18F#51, the
`UnhandledPromiseRejectionWarning` and `PromiseRejectionHandledWarning`
warnings were apparently added in v6.6.0
(https://nodejs.org/en/blog/release/v6.6.0/); specifically it was added
by nodejs/node#8223. See also:

  nodejs/node#6439
  nodejs/node#8217
  https://nodejs.org/dist/latest-v6.x/docs/api/process.html#process_event_unhandledrejection
  https://nodejs.org/dist/latest-v6.x/docs/api/process.html#process_event_rejectionhandled
  https://nodejs.org/dist/latest-v6.x/docs/api/process.html#process_event_warning

Test failures from `test/integration-test.js` after upgrading to Node
v6.9.1 showed extra output such as:

```
  (node:39696) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): null
  (node:39696) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 2)
```

This was happening because `scripts/slack-github-issues.js` created a
Hubot listener that returned a `Promise` so that the integration test
could use `.should.be.rejectedWith` assertions. Rather than jump through
hoops to quash the warnings, this change now causes the listener's
`catch` handler to return the result of the rejected `Promise`,
converting it to a fulfilled `Promise` in the process.

Since Hubot never used the result anyway, the only effect it has in
production is to eliminate the warning messages. The tests now just
check that the `Promise` returned by the listener callback is fulfilled
with the expected error result, with practically no loss in clarity.
@mgwalker
Copy link
Member

mgwalker commented Jan 15, 2017

@mbland If you'll PR from your fork back over here, I'll get it merged and updated on npm!

Update

On second thought, I'll update this to be a wrapper around your slack-github-issues module, similar to what you did with your fork. 👍

@mbland
Copy link
Contributor

mbland commented Jan 15, 2017

@mgwalker Actually, if you don't mind, I'd like to take sole ownership of the hubot-slack-github-issues NPM. I intend to keep actively maintaining and extending it moving forward. (I've only paused recently due to lots of intense work on mbland/go-script-bash, for which I'm about to push a new release this evening.)

@mgwalker
Copy link
Member

That also sounds good to me. Is there anything we need to do in npm so you can publish it?

@mbland
Copy link
Contributor

mbland commented Jan 15, 2017

Not really, I don't think. I still have publishing access to the NPM, so I can push a new version with the GitHub repo pointing to my fork. I'll give it a try in a few minutes here.

@mbland
Copy link
Contributor

mbland commented Jan 15, 2017

OK, done. That was easy.

@mgwalker
Copy link
Member

Fantastic, thanks! I'll finish updating our hubot. I've also put in a PR to update our readme to point to your repo instead. 😃

@wslack wslack closed this as completed in #54 Feb 2, 2017
mbland added a commit to mbland/unit-testing-node that referenced this issue Apr 28, 2017
Backported from mbland/hubot-slack-github-issues#7.

As discovered in 18F/hubot-slack-github-issues#51, the
`UnhandledPromiseRejectionWarning` and `PromiseRejectionHandledWarning`
warnings were apparently added in v6.6.0
(https://nodejs.org/en/blog/release/v6.6.0/); specifically it was added
by nodejs/node#8223. See also:

  nodejs/node#6439
  nodejs/node#8217
  https://nodejs.org/dist/latest-v6.x/docs/api/process.html#process_event_unhandledrejection
  https://nodejs.org/dist/latest-v6.x/docs/api/process.html#process_event_rejectionhandled
  https://nodejs.org/dist/latest-v6.x/docs/api/process.html#process_event_warning

A test failure from `solutions/06-integration/test/integration-test.js`
after upgrading to Node v6.9.1 showed output such as:

```
-  "(node:87412) UnhandledPromiseRejectionWarning: Unhandled
     promise rejection (rejection id: 14): Error: failed to create a
     GitHub issue in 18F/handbook: received 500 response from GitHub
     API: {\"message\":\"test failure\"}\n"
```

This was happening because `scripts/slack-github-issues.js`
ignored the return value from `Middleware.execute()`, whether it was
undefined or a `Promise`. For consistency's sake (and to provide a
clearer upgrade path to the current state of
mbland/slack-github-issues), `Middleware.execute()` always returns a
`Promise`, and `scripts/slack-github-issues.js` handles and ignores any
rejected Promises.

This fixed the `integration-test.js` error, but also required minor
updates to `solutions/{05-middleware,complete}/test/middleware-test.js`.
The next commit will update the tutorial narrative to account for this
change.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants