diff --git a/pkg/downloader/uri.go b/pkg/downloader/uri.go index 80214f5b860d..46685470ca2f 100644 --- a/pkg/downloader/uri.go +++ b/pkg/downloader/uri.go @@ -179,6 +179,10 @@ func DownloadFile(url string, filePath, sha string, downloadStatus func(string, } defer resp.Body.Close() + if resp.StatusCode >= 400 { + return fmt.Errorf("failed to download file %q, invalid status code %d", filePath, resp.StatusCode) + } + // Create parent directory err = os.MkdirAll(filepath.Dir(filePath), 0755) if err != nil {