probot: robot.on() throws on installation.deleted

robot.on() fetches a new token using the payload’s installation id. However, if that installation doesn’t exist (as is the case if one was just deleted), robot.on() will throw and the event handler won’t run.

This is of course an edge-case; how could GitHub send the installation id of an installation that doesn’t exist? Well, if it was just deleted of course!

Here’s what the error message looks like:

  err: {
    "code": 404,
    "status": "Not Found",
    "message": "{\"message\":\"Not Found\",\"documentation_url\":\"https://developer.github.com/v3/apps/#create-a-new-installation-token\"}"
  }
  --
  event: {
    "id": "4691d930-ee69-11e7-8126-16c94070ecf0",
    "event": "installation.deleted",
    "installation": 123
  }

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 3
  • Comments: 15 (8 by maintainers)

Most upvoted comments

robot.on('installation.deleting', async context => { // robot.on will throw
  
  return context.github.issues.createComment(...)
// call installation.deleted
## })

It’ll be something like this.

@aryannarora some pseudo code to illustrate what I meant:

robot.on('installation.deleted', async context => { // robot.on will throw
  // This will never be run
  return context.github.issues.createComment(...)
})

Within robot.auth, which robot.on uses under the hood, the part where it authenticates the context.github client as the installation throws an error.