Skip to content

Conversation

@joshuamkite-nfb
Copy link
Contributor

🧠 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

  • I understand that all AI assistance must be disclosed.
  • I did not use AI tools in this contribution.
  • I used AI tools and have disclosed details below.

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 code parameter that GitHub only provides during fresh installations, not during repository updates.

Root Cause

GitHub's OAuth flow differs between new installations and updates:

  • Fresh installation: Provides code parameter for OAuth validation
  • Repository update: No code parameter, changes delivered via webhook

The callback handler rejected all requests without code, breaking repository updates.

Solution

Made code parameter 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 InstallationRepositoriesEvent to process repository additions and removals.

Changes

  • backend/controllers/github_callback.go: Make code parameter optional
  • backend/controllers/github_installation.go: Add webhook event handler
  • backend/controllers/github.go: Add webhook routing
  • backend/controllers/github_test.go: Add test coverage

Total: +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

- Make code parameter optional in callback handler
- Add webhook handler for InstallationRepositoriesEvent
- Add test coverage for repository add/remove events

Fixes issue where users cannot add/remove individual repositories
from existing GitHub App installations. GitHub only provides OAuth
code during fresh installations, not during repository updates.
@ZIJ ZIJ self-requested a review November 21, 2025 20:55
@ZIJ ZIJ merged commit ebc8d22 into diggerhq:develop Nov 21, 2025
7 checks passed
ZIJ added a commit that referenced this pull request Nov 21, 2025
ZIJ added a commit that referenced this pull request Nov 21, 2025
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

Successfully merging this pull request may close these issues.

2 participants