From ed82b6811e88074603abad87d6cac4185c270bf2 Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 19 Oct 2026 15:48:22 +1100 Subject: [PATCH] fix(forge): allow the GitHub extension to download archives from codeload (#1) * fix(forge): keep the archive download token out of errors * fix(forge): allow the GitHub extension to download archives from codeload --- forge/github/client.go | 14 +++++++++++++- forge/github/package.yaml | 1 + 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/forge/github/client.go b/forge/github/client.go index 1096314..d58cecc 100644 --- a/forge/github/client.go +++ b/forge/github/client.go @@ -2,10 +2,12 @@ package main import ( "context" + "errors" "fmt" "io" "log/slog" "net/http" + "net/url" "strings" "sync" @@ -212,7 +214,7 @@ func (c *GitHubClient) GetRepoArchive(ctx context.Context, owner, repo, ref stri } resp, err := http.DefaultClient.Do(req) if err != nil { - return nil, fmt.Errorf("fetch archive %s/%s@%s: %w", owner, repo, ref, err) + return nil, fmt.Errorf("fetch archive %s/%s@%s: %w", owner, repo, ref, withoutURL(err)) } if resp.StatusCode != http.StatusOK { body, _ := io.ReadAll(io.LimitReader(resp.Body, 2048)) @@ -222,6 +224,16 @@ func (c *GitHubClient) GetRepoArchive(ctx context.Context, owner, repo, ref stri return resp.Body, nil } +// withoutURL drops the request URL from a transport error. The pre-signed +// archive URL carries a token, so it must not reach logs or task errors. +func withoutURL(err error) error { + var uerr *url.Error + if errors.As(err, &uerr) { + return uerr.Err + } + return err +} + // ListReviews returns the reviews on a PR with ID > sinceID. func (c *GitHubClient) ListReviews(ctx context.Context, owner, repo string, number int, sinceID int64) ([]forge.Review, error) { var out []forge.Review diff --git a/forge/github/package.yaml b/forge/github/package.yaml index f75e5ab..d02fd78 100644 --- a/forge/github/package.yaml +++ b/forge/github/package.yaml @@ -10,6 +10,7 @@ authority: egressHosts: - api.github.com - github.com + - codeload.github.com files: - path: bin/github mode: 493