Fix GitHub App OAuth flow for repository updates #2471
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🧠 AI Assistance Disclosure Policy
Important
Inspired by ghostty.
If you used any AI assistance while contributing to Digger, you must disclose it in this PR.
✅ AI Disclosure Checklist
Details:
This PR was written primarily by Claude (Roo Code mode). The solution was reviewed and tested by me as human contributor.
Problem
Users cannot add or remove individual repositories from an existing GitHub App installation. The OAuth callback handler requires a
codeparameter that GitHub only provides during fresh installations, not during repository updates.Root Cause
GitHub's OAuth flow differs between new installations and updates:
codeparameter for OAuth validationcodeparameter, changes delivered via webhookThe callback handler rejected all requests without
code, breaking repository updates.Solution
Made
codeparameter optional in the callback handler. When absent, show success page and let the webhook handle repository changes. When present, proceed with existing OAuth flow.Added webhook handler for
InstallationRepositoriesEventto process repository additions and removals.Changes
backend/controllers/github_callback.go: Make code parameter optionalbackend/controllers/github_installation.go: Add webhook event handlerbackend/controllers/github.go: Add webhook routingbackend/controllers/github_test.go: Add test coverageTotal: +120 lines, -3 lines
Testing
All unit tests pass. New test verifies repository addition and removal via webhook events. Not practical to do End-to-End/integration tests as we do not host our own Digger backend.
Behaviour
Before: Fresh installations work, repository updates fail
After: Both fresh installations and repository updates work