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

Warn developer when using un-registered hook #1042

Open
MaximDevoir opened this issue Oct 20, 2019 · 6 comments · May be fixed by #1078
Open

Warn developer when using un-registered hook #1042

MaximDevoir opened this issue Oct 20, 2019 · 6 comments · May be fixed by #1078

Comments

@MaximDevoir
Copy link
Contributor

@MaximDevoir MaximDevoir commented Oct 20, 2019

Feature Request

Warn developers when they are attempting to hook onto an event that the app/installation is not subscribed to.

I don't remember where I saw this, but I believe there is an endpoint that returns all the events an installation (app) is subscribed to.

Is your feature request related to a problem? Please describe.

This would warn users in situations like #969 #933 #857 and any other related issue below 857 (i'm not gonna search all day 😄 ).

Example

app.on('issues.opened', async context => {
  const issueComment = context.issue({ body: 'Thanks for opening this issue!' })
  return context.github.issues.createComment(issueComment)
}) 
// logged to console:
// [WARN]: Installation is not subscribed to `issues` event.
//       : See <link here> on how to subscribe to 'issues.opened' event.
@issue-label-bot

This comment has been minimized.

Copy link

@issue-label-bot issue-label-bot bot commented Oct 20, 2019

Issue-Label Bot is automatically applying the label enhancement ➕ to this issue, with a confidence of 0.98. Please mark this comment with 👍 or 👎 to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

@gr2m

This comment has been minimized.

Copy link
Contributor

@gr2m gr2m commented Oct 20, 2019

Yeah I wish that existed, but I don't know how it would work (efficiently). It will require an extra request, maybe we could add a --debug flag to add additional checks?

@MaximDevoir

This comment has been minimized.

Copy link
Contributor Author

@MaximDevoir MaximDevoir commented Oct 20, 2019

At best, this requires one additional request as the application starts up. I think it should be on by default.

And of course this feature should be disabled in production mode or with the passing of an environment variable (similar to DISABLE_STATS).

@gr2m

This comment has been minimized.

Copy link
Contributor

@gr2m gr2m commented Oct 21, 2019

ok, I think if you or someone else wants to start a PR to discuss over code, that'd be great

@MaximDevoir

This comment has been minimized.

Copy link
Contributor Author

@MaximDevoir MaximDevoir commented Oct 21, 2019

The integrations API includes endpoints to view the events/permissions of an installation.

Sadly, there are no "free" or guaranteed endpoints that Probot could access to get the current installations' permissions & events.

@gr2m

This comment has been minimized.

Copy link
Contributor

@gr2m gr2m commented Oct 21, 2019

Shouldn't that one work?

https://developer.github.com/v3/apps/#response-1

GET /app responds with an array of events the app is subscribed to

GitHub Developer
Get started with one of our guides, or jump straight into the API documentation.
@MaximDevoir MaximDevoir reopened this Oct 21, 2019
@MaximDevoir MaximDevoir linked a pull request that will close this issue Dec 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.