Skip to content

feat(github): Handle installation_repositories webhook#112227

Open
wedamija wants to merge 2 commits intomasterfrom
danf/github-installation-repositories-take-2
Open

feat(github): Handle installation_repositories webhook#112227
wedamija wants to merge 2 commits intomasterfrom
danf/github-installation-repositories-take-2

Conversation

@wedamija
Copy link
Copy Markdown
Member

@wedamija wedamija commented Apr 3, 2026

This failed due to SENTRY-5MSP. This was caused by us not deploying routings to control first, and so we tried to fire a control task from a cell. That's fixed in #112226. Other than that, this is the same as the previous pr and doesn't need re-review

Currently, we only sync the available repositories from Github on installing the integration. So over time, if new repositories are added to the github organization, or access to specific repositories is added or removed, we end up out of sync with which repositories we store in Sentry.

To fix this, we are going to start handling the installation_repositories webhook. This is fired whenever the repositories that a github app can access change. This allows us to keep all the repos in sync.

Note that when access to a repo is removed, we only ever disable the repo and never delete it. This allows us to keep the history of commits and so on so far.

@wedamija wedamija requested a review from a team April 3, 2026 20:17
@wedamija wedamija requested review from a team as code owners April 3, 2026 20:17
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Apr 3, 2026
@wedamija wedamija changed the title Danf/GitHub installation repositories take 2 feat(github): Handle installation_repositories webhook Apr 3, 2026
@wedamija wedamija force-pushed the danf/github-installation-repositories-take-2 branch from b9e0b43 to 04536e2 Compare April 3, 2026 20:23
Copy link
Copy Markdown
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

pass

if repos_removed:
external_ids = [str(repo["id"]) for repo in repos_removed]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent error handling for repos_removed vs repos_added

Low Severity

In _sync_repos_for_org, the repos_added processing wraps each get_repo_config call in a try/except KeyError to gracefully skip malformed entries and continue. However, the repos_removed processing uses a bare list comprehension ([str(repo["id"]) for repo in repos_removed]) with no error handling, so a single malformed entry causes the entire disable operation to fail. Since repos_added runs first, this can lead to repos being created but corresponding removals not being processed.

Additional Locations (1)
Fix in Cursor Fix in Web

Base automatically changed from danf/installation-repositories-routing to master April 3, 2026 22:17
wedamija added 2 commits April 3, 2026 15:17
This failed due to SENTRY-5MSP.

Currently, we only sync the available repositories from Github on installing the integration. So over time, if new repositories are added to the github organization, or access to specific repositories is added or removed, we end up out of sync with which repositories we store in Sentry.

To fix this, we are going to start handling the `installation_repositories` webhook. This is fired whenever the repositories that a github app can access change. This allows us to keep all the repos in sync.

Note that when access to a repo is removed, we only ever disable the repo and never delete it. This allows us to keep the history of commits and so on so far.
@wedamija wedamija force-pushed the danf/github-installation-repositories-take-2 branch from 04536e2 to dda0538 Compare April 3, 2026 22:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant