Skip to content

github installation callback missing the "code" parameter #1879

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

Open
motatoes opened this issue Jan 31, 2025 · 3 comments
Open

github installation callback missing the "code" parameter #1879

motatoes opened this issue Jan 31, 2025 · 3 comments

Comments

@motatoes
Copy link
Contributor

in some cases github when an app installation is being updated it decides to not send a code paramter which we expect to recieve here:

func (d DiggerController) GithubAppCallbackPage(c *gin.Context) {
installationId := c.Request.URL.Query()["installation_id"][0]
//setupAction := c.Request.URL.Query()["setup_action"][0]
code := c.Request.URL.Query()["code"][0]
appId := c.Request.URL.Query().Get("state")
clientId, clientSecret, _, _, err := d.GithubClientProvider.FetchCredentials(appId)
if err != nil {
log.Printf("could not fetch credentials for the app: %v", err)

this causes an exception on callback and we need to handle it properly. The callback from github sometimes look like this: /github/callback?installation_id=1234567890&setup_action=update

In this case we need to handle a missing code parameter and then lookup the installation_id from the db records then perform the update accordingly somehow TBD

@midu-git
Copy link

During the installation of Digger as a GitHub App, Digger sets Request user authorization (OAuth) during installation. This leads to the callback being called as an installation step. As a result code is provided to the callback, to be exchanged by a user access token. On subsequent update requests on the apps setting page, the code won't be send any more. Thus, with your setup, you can expect code for the first time installation, and the following request to the callback url won't provide it. See here

Moreover, you should not relay on the installation_id provided to the callback url, see here.

Anyway, are there any plans to fix this issue. I'm currently unable to update the settings to include additional repositories because of the code dependency. The workaround is to re-install the app again, which is not a good experience.

@asosso
Copy link
Contributor

asosso commented May 2, 2025

@midu-git I tried a fresh installation of Digger using version v0.6.97 with a clean database, creating a new GitHub App.
The issue no longer occurs.

@midu-git
Copy link

midu-git commented May 6, 2025

@asosso have you tried to add another repo after you've installed the application for the first time? In my case, no code parameter is send and Digger (also v0.6.97) errors out.

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

3 participants