fix: correct GHES URL wiring and Docker client build args - #2
Conversation
There was a problem hiding this comment.
Pull request overview
This PR closes remaining gaps in GHE.com / GHES support: it adds proper GraphQL endpoint derivation, ensures the Octokit GraphQL client (including Probot's) targets the right host, makes generateAuthUrl() honor the configured protocol, forwards NEXT_PUBLIC_* build args through the Dockerfile, and adds a server-side warning when GITHUB_USER_EMAIL_DOMAIN is left unset on non-github.com deployments. Documentation and focused integration tests are added/updated accordingly.
Changes:
- Introduce
getGitHubGraphQlUrl()/getGitHubServerProtocol()and wire them into Octokit, Probot, and authenticated git remotes. - Extract
createGitHubUserinfoRequestand addgetCommitterEmailDomainWithWarning(one-shot warning) for non-github.com hosts. - Forward
NEXT_PUBLIC_GITHUB_SERVER_URL/NEXT_PUBLIC_GITHUB_API_URLas Docker build args, update README/docs/.env.example, and add integration tests covering all of the above.
Show a summary per file
| File | Description |
|---|---|
| src/utils/github-urls.ts | Adds getGitHubGraphQlUrl, getGitHubServerProtocol, and a shared isGithubDotComHost helper. |
| src/utils/auth.ts | generateAuthUrl now preserves the configured server protocol. |
| src/utils/server/committer-email.ts | New helper logging a one-time warning when default email domain is used on non-github.com servers. |
| src/bot/rest.ts | Adds githubGraphQlEndpointPlugin and registers it on the shared Octokit. |
| src/bot/octokit.ts (context) | generateAppAccessToken already uses derived REST baseUrl. |
| src/pages/api/webhooks.ts | Applies the GraphQL endpoint plugin to Probot's Octokit. |
| src/app/api/auth/lib/nextauth-options.ts | Extracts createGitHubUserinfoRequest to use the configured API host. |
| src/server/git/controller.ts, src/server/repos/controller.ts | Switch to getCommitterEmailDomainWithWarning. |
| scripts/webhook-relay.mjs | Adds a sync-with-github-urls comment for the local REST URL derivation. |
| Dockerfile | Accepts and exports NEXT_PUBLIC_GITHUB_SERVER_URL / NEXT_PUBLIC_GITHUB_API_URL before npm run build. |
| README.md, docs/developing.md, .env.example | Document the Dockerfile already forwards the build args and the new warning behavior. |
| test/github-urls.test.ts | New GraphQL/protocol assertions, including explicit GHES /api/v3 override. |
| test/bot/octokit.test.ts | Verifies REST + GraphQL endpoints for GHES and GHE.com, plus app auth baseUrl. |
| test/app/api/auth/nextauth-options.test.ts | Covers email fallback against the configured API host. |
| test/utils/auth.test.ts | Covers protocol/host handling in generateAuthUrl. |
| test/utils/server/committer-email.test.ts | Verifies one-time warning and explicit-domain behavior. |
| test/docs/docker-build-config.test.ts | Ensures Dockerfile and docs stay in sync about build args. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 19/19 changed files
- Comments generated: 0
|
@copilot apply these non-critical changes from review The path aliasing for the mocked 'utils/pem' module should work if Vitest is configured with the same TypeScript path aliases, and since the author claims the tests pass, I'll assume that's handled correctly. I notice isGithubDotComServer in committer-email.ts duplicates logic that already exists as isGithubDotComHost in github-urls.ts—a minor redundancy but not critical. Overall the review looks solid with no major issues to flag. |
Fixed the |
Pull Request
Proposed Changes
This updates the GHE.com / GHES support work to close the remaining gaps in endpoint resolution and client build-time configuration. The main fixes are correct GHES GraphQL routing, Docker forwarding of
NEXT_PUBLIC_*values, protocol-safe auth URLs, and integration coverage for the affected wiring.GraphQL endpoint resolution
getGitHubGraphQlUrl()to derive the correct endpoint for:github.com→https://api.github.com/graphql*.ghe.com→https://api.<tenant>.ghe.com/graphqlhttps://<host>/api/graphqlbaseUrlinference for GHES.Client build-time GitHub host configuration
Dockerfilebuilder stage to accept and export:NEXT_PUBLIC_GITHUB_SERVER_URLNEXT_PUBLIC_GITHUB_API_URLAuth and server-side URL consistency
generateAuthUrl()to preserve the configured GitHub server protocol and host instead of hardcodinghttps://.github.comserver is configured butGITHUB_USER_EMAIL_DOMAINis not set.Shared derivation rules / drift reduction
src/utils/github-urls.ts.Focused integration coverage
userinfo.requestemail fallback using the configured API hostgenerateAuthUrl()host/protocol handlingNEXT_PUBLIC_*build argsExample of the GHES-specific behavior this change locks in:
Readiness Checklist
Author/Contributor
npm run formatand fix any formatting issues that have been introducednpm run lintand fix any linting issues that have been introducednpm run testand run tests