From a25294d68c6cae309451af657b96846e1775ef57 Mon Sep 17 00:00:00 2001 From: Jon Johnson Date: Fri, 24 Jan 2025 10:31:07 -0800 Subject: [PATCH] Return an if fetching index fails (#1495) We weren't actually checking the response code, so we get weird gzip errors instead of the HTTP status. Signed-off-by: Jon Johnson --- pkg/apk/apk/index.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/apk/apk/index.go b/pkg/apk/apk/index.go index e16a1dcf..94d65341 100644 --- a/pkg/apk/apk/index.go +++ b/pkg/apk/apk/index.go @@ -135,6 +135,10 @@ func (i *indexCache) get(ctx context.Context, repoName, repoURL string, keys map return nil, err } + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("unexpected status code %d", resp.StatusCode) + } + fetchAndParse := func(etag string) (NamedIndex, error) { b, err := fetchRepositoryIndex(ctx, u, etag, opts) if err != nil {