Skip to content

feat(github-enterprise): Route installation_repositories to control silo#112245

Open
wedamija wants to merge 1 commit intodanf/repo-sync-audit-logsfrom
danf/ghe-routing
Open

feat(github-enterprise): Route installation_repositories to control silo#112245
wedamija wants to merge 1 commit intodanf/repo-sync-audit-logsfrom
danf/ghe-routing

Conversation

@wedamija
Copy link
Copy Markdown
Member

@wedamija wedamija commented Apr 3, 2026

Remove the should_route_to_control_silo override in GithubEnterpriseRequestParser so it inherits the parent's routing, which sends installation_repositories events to control silo.

We do this to make sure the webhooks for GHE will also route to the right place

Remove the should_route_to_control_silo override in GithubEnterpriseRequestParser so it inherits the parent's routing, which sends installation_repositories events to control silo.

We do this to make sure the webhooks for GHE will also route to the right place
@wedamija wedamija requested a review from a team April 3, 2026 23:26
@wedamija wedamija requested a review from a team as a code owner April 3, 2026 23:26
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Apr 3, 2026
Comment on lines 18 to 23
webhook_identifier = WebhookProviderIdentifier.GITHUB_ENTERPRISE
webhook_endpoint = GitHubEnterpriseWebhookEndpoint

def should_route_to_control_silo(
self, parsed_event: Mapping[str, Any], request: HttpRequest
) -> bool:
# GHE only routes installation events to control silo.
# installation_repositories is not yet supported for GHE.
return request.META.get(GITHUB_WEBHOOK_TYPE_HEADER) == GithubWebhookType.INSTALLATION

def _get_external_id(self, event: Mapping[str, Any]) -> str | None:
host = get_host(request=self.request)
if not host:
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.

Bug: Removing the should_route_to_control_silo override routes installation_repositories webhooks for GHE, but the GitHubEnterpriseWebhookEndpoint lacks a handler, causing these events to be silently dropped.
Severity: HIGH

Suggested Fix

Implement a GitHubEnterpriseInstallationRepositoriesEventWebhook handler, similar to the existing InstallationRepositoriesEventWebhook for regular GitHub. Register this new handler in the _handlers dictionary within GitHubEnterpriseWebhookEndpoint for the GithubWebhookType.INSTALLATION_REPOSITORIES event type. This will ensure that repository changes for GitHub Enterprise installations are processed correctly.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: src/sentry/middleware/integrations/parsers/github_enterprise.py#L18-L23

Potential issue: The pull request removes an override in
`GithubEnterpriseRequestParser`, causing it to inherit the parent's behavior of routing
`installation_repositories` webhooks to the control silo. However, the
`GitHubEnterpriseWebhookEndpoint` does not have a handler registered for this event
type. As a result, when a GitHub Enterprise instance sends an
`installation_repositories` webhook, the endpoint's `_handle` method will find no
handler and silently return a `204` status. This prevents the necessary repository
synchronization tasks from running when repositories are added to or removed from a GHE
app installation.

Did we get this right? 👍 / 👎 to inform future reviews.

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