From d85266f756ce9182c603ae55e420249fe9201a14 Mon Sep 17 00:00:00 2001 From: Chris Wiggins Date: Wed, 23 Jul 2025 17:01:20 -0600 Subject: [PATCH 1/2] fix: check for response code 200, if not 200 return the error --- pkg/engine/config.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/engine/config.go b/pkg/engine/config.go index e2cc1daf..5da3e6c9 100644 --- a/pkg/engine/config.go +++ b/pkg/engine/config.go @@ -185,9 +185,14 @@ func downloadUpdateConfigFile(urlStr string, existsAlready, initial bool, pat, u return false, err } defer resp.Body.Close() + + if resp.StatusCode != http.StatusOK { + return false, fmt.Errorf("received non-200 HTTP status: %d %s", resp.StatusCode, resp.Status) + } + newBytes, err := io.ReadAll(resp.Body) if err != nil { - return false, fmt.Errorf("error downloading config from %s: %v", err) + return false, fmt.Errorf("error downloading config from %s: %v", urlStr, err) } if newBytes == nil { // if initial, this is the last resort, newBytes should be populated From 18b7cf6321756bf0c2b23023da9b69dbc8186f80 Mon Sep 17 00:00:00 2001 From: Chris Wiggins <5607419+cwiggs@users.noreply.github.com> Date: Thu, 24 Jul 2025 13:26:12 -0600 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com> --- pkg/engine/config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/engine/config.go b/pkg/engine/config.go index 5da3e6c9..9d2b1e1a 100644 --- a/pkg/engine/config.go +++ b/pkg/engine/config.go @@ -187,7 +187,7 @@ func downloadUpdateConfigFile(urlStr string, existsAlready, initial bool, pat, u defer resp.Body.Close() if resp.StatusCode != http.StatusOK { - return false, fmt.Errorf("received non-200 HTTP status: %d %s", resp.StatusCode, resp.Status) + return false, fmt.Errorf("received non-200 HTTP status from %s: %d %s", urlStr, resp.StatusCode, resp.Status) } newBytes, err := io.ReadAll(resp.Body)