feat(github): Handle installation_repositories webhook#112227
feat(github): Handle installation_repositories webhook#112227
Conversation
b9e0b43 to
04536e2
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
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] |
There was a problem hiding this comment.
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)
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.
04536e2 to
dda0538
Compare


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_repositorieswebhook. 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.