Skip to content

Commit

Permalink
fix: ensure cacheTransport returns an error for non-200 responses (#1381
Browse files Browse the repository at this point in the history
)

Currently there is a bug in `cacheTransport` I found when working on
#1378 where non-success status codes do not result in a returned `error`
(despite exiting early) resulting in other confusing/hard to debug
problems later on.

Signed-off-by: Luke Young <[email protected]>
  • Loading branch information
lyoung-confluent authored Nov 7, 2024
1 parent cd765e7 commit 81ff6a3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/apk/apk/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,10 @@ func (t *cacheTransport) retrieveAndSaveFile(ctx context.Context, request *http.
return "", fmt.Errorf("wrapped client is nil")
}
resp, err := t.wrapped.Do(request)
if err != nil || resp.StatusCode != 200 {
if err != nil {
return "", err
} else if resp.StatusCode != 200 {
return "", fmt.Errorf("unexpected status code %d", resp.StatusCode)
}

// Determine the file we will caching stuff in based on the URL/response
Expand Down

0 comments on commit 81ff6a3

Please sign in to comment.