feat(github-enterprise): allow github.com as a source for the GitHub Enterprise integration#115599
Draft
tnt-sentry wants to merge 13 commits into
Draft
feat(github-enterprise): allow github.com as a source for the GitHub Enterprise integration#115599tnt-sentry wants to merge 13 commits into
tnt-sentry wants to merge 13 commits into
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
github.comas a third recognized host for the existinggithub_enterpriseintegration, 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:
*.ghe.comhttps://api.{host}/X-Github-Tenantheadergithub.comhttps://api.github.com/https://{host}/api/v3/X-GitHub-Enterprise-HostheaderThe github.com variant mirrors GHE Cloud's API URL pattern (no
/api/v3rewrite,api.{host}subdomain) but diverges on webhook routing: github.com sends neitherX-GitHub-Enterprise-HostnorX-Github-Tenant, so a dedicated webhook URL/extensions/github-enterprise/webhook/github-com/is registered. The new endpoint hardcodeshost = "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 parentGithubRequestParser.get_responselearns to toleratewebhook_endpointbeing a tuple so the first-partygithubparser (single-class) keeps working.Coexistence with the first-party
githubintegrationDistinct provider keys and distinct
external_idformats guarantee coexistence without any enforcement code:github:external_id = installation_idgithub_enterpriseon 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 rejectsgithub.comwith a user-facing field error unless the org has the flag. Existing GHES and GHE Cloud installs are unaffected.