-
Notifications
You must be signed in to change notification settings - Fork 8.8k
Comparing changes
Open a pull request
base repository: cli/cli
base: trunk
head repository: cli/cli
compare: williammartin-api-host-proxy-test
- 6 commits
- 13 files changed
- 2 contributors
Commits on Jul 31, 2026
-
Add api_host gateway black box test
A bash harness that runs the real gh binary against a recording TLS reverse proxy, with api.github.com blackholed, to prove that api_host in hosts.yml routes API traffic through a gateway while still returning real results from github.com. It runs in a Linux container because api_host cannot carry a port, so the gateway needs :443, and because Go only honours SSL_CERT_FILE off macOS. Phase 1 is expected to fail today: gh derives its own endpoints in internal/ghinstance and never consults api_host. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 7e37f9a3-d447-474d-a800-2922d2d09f59
Configuration menu - View commit details
-
Copy full SHA for 5afdeb5 - Browse repository at this point
Copy the full SHA 5afdeb5View commit details -
Bind before writing the gateway CA
A gateway that fails to bind was overwriting the CA file that a running one is serving with, which then looks like an unrelated TLS trust failure. Also document driving the gateway directly with curl. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 7e37f9a3-d447-474d-a800-2922d2d09f59
Configuration menu - View commit details
-
Copy full SHA for 75b2ae7 - Browse repository at this point
Copy the full SHA 75b2ae7View commit details -
Assert paginated requests keep the token
Running the harness against a naive implementation showed the follow-up request to a gateway-provided pagination URL arriving without an Authorization header, because the token is looked up by request host and the gateway host has no token. It only passed because labels are public; anything private would break. go-gh permits authorization for the configured API host for this exact reason, so assert it here too. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 7e37f9a3-d447-474d-a800-2922d2d09f59
Configuration menu - View commit details
-
Copy full SHA for 0d62179 - Browse repository at this point
Copy the full SHA 0d62179View commit details -
Document the pagination token trap
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 7e37f9a3-d447-474d-a800-2922d2d09f59
Configuration menu - View commit details
-
Copy full SHA for 2a7dc9d - Browse repository at this point
Copy the full SHA 2a7dc9dView commit details -
Point go-gh at the per-host api_host branch
This is a spike dependency on cli/go-gh#275, not a mergeable pin. It is enough on its own to make `gh repo view` honour api_host, because api.Client.Query hands the real hostname to go-gh's NewGraphQLClient and the branch swaps the endpoint inside that constructor. Commands that build their own URLs from internal/ghinstance, such as `gh api`, are unaffected and still need work. go mod tidy pulled transitive upgrades along with it: chroma, gojq, timefmt-go and go-timezone-local. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 7e37f9a3-d447-474d-a800-2922d2d09f59
Configuration menu - View commit details
-
Copy full SHA for ffbb5c2 - Browse repository at this point
Copy the full SHA ffbb5c2View commit details -
Send a host's token to its configured api_host
go-gh routes API requests for a host to that host's api_host, which is a hostname gh is not logged in to. AddAuthTokenHeader resolves tokens by request host, found nothing for it, and sent the request anonymously, so `gh repo view` through a gateway got a 401. go-gh solves this in its own headerRoundTripper, but that is inert for us: cli/cli sets AuthToken "none" and an empty Authorization header to opt out of go-gh's token resolution, because it needs per-request hosts and keyring lookups that go-gh cannot express. So we resolve it again on our side. AuthConfig owns the api_host to host mapping, since it owns hosts.yml, and the API transport decides to apply it. It is deliberately not folded into ActiveToken: the git credential helper passes a hostname straight from git, so that would hand a github.com token to whatever host is configured as api_host for git operations, and api_host governs API traffic only. The mapping is a fallback used only when the request host has no token of its own, so it can only add a token where there would have been none and every host we already authenticate resolves exactly as before. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 7e37f9a3-d447-474d-a800-2922d2d09f59
Configuration menu - View commit details
-
Copy full SHA for 37a8246 - Browse repository at this point
Copy the full SHA 37a8246View commit details
This comparison is taking too long to generate.
Unfortunately it looks like we can’t render this comparison for you right now. It might be too big, or there might be something weird with your repository.
You can try running this command locally to see the comparison on your machine:
git diff trunk...williammartin-api-host-proxy-test