bulldozer icon indicating copy to clipboard operation
bulldozer copied to clipboard

Could not refresh token

Open nambrot opened this issue 5 years ago • 8 comments

I just tried to run bulldozer and I'm getting the following or similar errors when receiving events from Github:

Get https://api.github.com/repos/celo-org/celo-monorepo/pulls?per_page=100&state=open: could not refresh installation id 524951's token: received non 2xx response status "404 Not Found" when fetching https://api.github.com/installations/524951/access_tokens

The installation ID is correct, so I'm not sure what the difficulty is, and I'm quite new to Golang. Are there any points for debugging this?

nambrot avatar Dec 18 '18 18:12 nambrot

It looks like this is an issue with URL generation: according to the API docs, your URL is missing an /app/ section.

From this blog post, GitHub announced they were removing the old route on September 4, 2018.

However, we're currently running Bulldozer (and other apps) targeting the palantir organization on github.com and I haven't seen this error yet, so I'm not sure why you've run into it here.

https://github.com/bradleyfalzon/ghinstallation/pull/17 updates the library we use for authentication, but hasn't merged yet. We could also work around this by updating the BaseURL we configure in the transport, but I'm not sure how to do this in a way that's compatible with both github.com and GitHub Enterprise (which may not have the API change yet).

As a test, and assuming you are running or building from source, can you try this?

  1. Open vendor/github.com/palantir/go-githubapp/githubapp/client_creator.go
  2. Replace lines 169 and 180 with:
    itr.BaseURL = strings.TrimSuffix(c.v3BaseURL, "/") + "/app"
    
  3. Rebuild and redeploy the server

bluekeyes avatar Dec 18 '18 19:12 bluekeyes

Fwiw, I'm using the provided docker image if that makes a difference. I'll try to build with your suggestions, thank you!

nambrot avatar Dec 18 '18 22:12 nambrot

I couldn't really figure out how to build it from scratch, so for now, I'll just wait for upstream to get fixed

nambrot avatar Dec 27 '18 02:12 nambrot

☝️ I got the same issue and tried @bluekeyes's approach, but it also fails with a similar error message.

erickmendonca avatar Apr 23 '19 23:04 erickmendonca

It looks like the change to ghinstallation merged last week, so we can try upgrading to that now. But I have to admit that I'm still quite confused by this issue: we've been using the current release of Bulldozer against both github.com and GitHub Enterprise 2.16.5 without any issues. Maybe the API change only applies to application created after a certain date?

@erickmendonca if you have a build environment working, can you try upgrading the library?

./godelw run-dep -- ensure -update github.com/bradleyfalzon/ghinstallation

If that works, I'll have to verify that it still works against GitHub Enterprise as well before including it in a release.

bluekeyes avatar Apr 24 '19 00:04 bluekeyes

I got the same error today and I found out that in addition to update the api url to https://api.github.com/app, in the config file the integration_id value must be App id value of your app. You can find it on the General tab of your application (Settings > Developer settings > GitHub Apps > {your app} > General

tanvn avatar Apr 25 '19 09:04 tanvn

I got the same error today and I found out that in addition to update the api url to https://api.github.com/app, in the config file the integration_id value must be App id value of your app. You can find it on the General tab of your application (Settings > Developer settings > GitHub Apps > {your app} > General

@tanvn Did this resolve the issue for you?

ashishb avatar Aug 06 '19 00:08 ashishb

@ashishb Yes ! I did resolve the issue. And actual I am using the bulldozer:1.5.0 docker image, and there is no need to update the API url, only fill out the settings for bulldozer.yml is ok.

tanvn avatar Aug 06 '19 03:08 tanvn