fix(github): use api.github.com base URL for GitHub App auth (#1823)#1843
Open
hugh-fai wants to merge 1 commit into
Open
fix(github): use api.github.com base URL for GitHub App auth (#1823)#1843hugh-fai wants to merge 1 commit into
hugh-fai wants to merge 1 commit into
Conversation
…c#1823) The Setup() function was incorrectly using the web host (https://github.com) instead of the API host (https://api.github.com) when creating the go-scm client for GitHub App authentication. This caused 404 errors when the branch-planner attempted to list pull requests. For GitHub.com: - Now uses https://api.github.com (was: https://github.com) For GHE: - Now uses <server>/api/v3 for both transport.BaseURL and github.New() - Previously only set transport.BaseURL, but still passed the web host to New() This mirrors the pattern used in the token auth path where factory.NewClient properly calls ensureGHEEndpoint. Fixes flux-iac#1823
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.
Summary
Fixes #1823 — the branch-planner returns
404 Not Foundwhen listing pull requests under GitHub App authentication.Root cause
In
internal/git/provider/github_provider.go,Setup()builds the go-scm client for the App-auth path with the web hosthttps://github.cominstead of the API hosthttps://api.github.com:All subsequent REST calls (e.g. listing PRs) are then issued against
https://github.com/...and 404. The token auth path avoids this because it goes throughfactory.NewClient→ensureGHEEndpoint, which resolves the correct API host.Fix
Use the API host in the App path, mirroring the token path's
ensureGHEEndpointbehaviour:https://api.github.com(washttps://github.com).<server>/api/v3for bothtransport.BaseURLandgithub.New()(previously onlytransport.BaseURLwas set, while the web host was still passed toNew()).Verification
Built a patched branch-planner image from this fix and ran it against a live cluster with a GitHub App-authenticated branch-planner. Before: every poll logged
Not Found(404) when listing PRs. After: the branch-planner lists PRs successfully, discovers the open PR, and reconciles its Terraform planner object with zero 404s (0 error-level log lines across many poll cycles). The App-auth PR-listing path that #1823 reported is fixed.Fixes #1823