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
This commit is contained in:
sam authored and GitHub committed 2026-10-19 15:48:22 +11:00
1 parent e1377fbe98
commit ed82b6811e
2 files changed
+14 -1

No files matched your search

+13 -1
View File
@@ -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
+1
View File
@@ -10,6 +10,7 @@ authority:
egressHosts:
- api.github.com
- github.com
- codeload.github.com
files:
- path: bin/github
mode: 493