Skip to content

feat(github-enterprise): allow github.com as a source for the GitHub Enterprise integration#115599

Draft
tnt-sentry wants to merge 13 commits into
masterfrom
tnt-sentry/ghe-github-com-source
Draft

feat(github-enterprise): allow github.com as a source for the GitHub Enterprise integration#115599
tnt-sentry wants to merge 13 commits into
masterfrom
tnt-sentry/ghe-github-com-source

Conversation

@tnt-sentry
Copy link
Copy Markdown
Contributor

@tnt-sentry tnt-sentry commented May 14, 2026

Adds github.com as a third recognized host for the existing github_enterprise integration, alongside GitHub Enterprise Server (*.example.com) and GitHub Enterprise Cloud (*.ghe.com). Customers who want to install their own GitHub App on github.com — for example, large enterprise orgs that need a custom-branded app with controlled permissions rather than Sentry's shared first-party app — can now do so without standing up GHES.

Builds directly on PR #113966 (GHE.com support), which generalized the URL/host plumbing into a suffix-based discriminator. The third variant slots into that pattern.

Design

Three host variants are distinguished at runtime by the host string the customer enters in the install form:

Host Variant API base URL Webhook source
*.ghe.com GHE Cloud https://api.{host}/ X-Github-Tenant header
github.com github.com (new) https://api.github.com/ Dedicated webhook URL
anything else GHES https://{host}/api/v3/ X-GitHub-Enterprise-Host header

The github.com variant mirrors GHE Cloud's API URL pattern (no /api/v3 rewrite, api.{host} subdomain) but diverges on webhook routing: github.com sends neither X-GitHub-Enterprise-Host nor X-Github-Tenant, so a dedicated webhook URL /extensions/github-enterprise/webhook/github-com/ is registered. The new endpoint hardcodes host = "github.com" via a _get_host() hook method on the webhook base class, then runs the same downstream HMAC + event-dispatch flow.

The hybrid-cloud request parser (GithubEnterpriseRequestParser) is updated to recognize both webhook endpoints; the parent GithubRequestParser.get_response learns to tolerate webhook_endpoint being a tuple so the first-party github parser (single-class) keeps working.

Coexistence with the first-party github integration

Distinct provider keys and distinct external_id formats guarantee coexistence without any enforcement code:

  • First-party github: external_id = installation_id
  • github_enterprise on github.com: external_id = "github.com:{installation_id}"

An org can install both simultaneously (verified locally).

Gating

Behind feature flag organizations:github-enterprise-github-com-source (FlagPole). The install form rejects github.com with a user-facing field error unless the org has the flag. Existing GHES and GHE Cloud installs are unaffected.

tnt-sentry added 10 commits May 12, 2026 11:37
…n API client

Extend the GitHubEnterpriseApiClient discriminator to match github.com as well
as *.ghe.com hosts. Rename _is_ghe_cloud to _is_cloud_style to reflect that the
flag now covers two host families. The construction https://api.{base_url}
already produces https://api.github.com correctly for github.com.

Add three new tests validating github.com base_url construction and build_url
behavior for both regular paths and GraphQL endpoint. Existing tests for
*.ghe.com and self-hosted GHES continue to pass unchanged.
…_url

Extend _api_base_url to recognize github.com as a cloud-style instance
alongside .ghe.com domains, returning the API endpoint as
https://api.github.com instead of https://github.com/api/v3.

This change aligns with the discriminator logic added to client.py in
a previous task and is used by get_user_info and _get_ghe_installation_info
during installation.
Add a new webhook URL pattern for handling github.com webhook events
through a dedicated endpoint (GitHubEnterpriseGitHubComWebhookEndpoint).
This allows github.com webhooks to bypass the host detection and
configuration lookup, treating github.com as a fixed target.

The new endpoint is registered at /extensions/github-enterprise/webhook/github-com/
and routes to the GitHubEnterpriseGitHubComWebhookEndpoint class.
…ud parser

Extend GithubEnterpriseRequestParser to recognize both the legacy GHES
webhook endpoint and the new github.com endpoint. For the github.com
route, derive external_id using a hardcoded host of "github.com" instead
of get_host(), which returns None when no enterprise host headers are present.

Update the parent GithubRequestParser.get_response to handle webhook_endpoint
as either a single class or a tuple, so the view_class membership check
works correctly for both the github and github_enterprise parsers.
Reject InstallationConfigView form submissions targeting github.com
when the org lacks the organizations:github-enterprise-github-com-source
flag. GHES installs and flag-enabled orgs are unaffected.
…ithub.com

The help text now mentions github.com custom GitHub Apps, GitHub Enterprise Cloud
(GHE Cloud), and GitHub Enterprise Server (GHES) to clarify which types of
instances the form supports.
…tion coverage for github.com

Replace defensive positional/keyword branching in test_skips_get_host_uses_github_com
with a direct args[1] assertion — fails loudly if call convention changes.

Add BuildIntegrationGitHubComTest to verify build_integration produces a
'github.com:' prefixed external_id, ensuring coexistence with the first-party
github integration that uses a bare installation_id.
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label May 14, 2026
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