From 6a0f1aa3434b59b32cb4fd3ef62996b9ce90210b Mon Sep 17 00:00:00 2001 From: vimystic <122659254+vimystic@users.noreply.github.com> Date: Thu, 27 Jul 2023 03:24:03 -0600 Subject: [PATCH 1/4] Add status check to ensure we gracefully discontinue --- cmd/queue.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/queue.go b/cmd/queue.go index 7f7ef5f..e486214 100644 --- a/cmd/queue.go +++ b/cmd/queue.go @@ -44,7 +44,7 @@ func mostRecentReleasesForChain( } res, err := client.Do(req) - if err != nil { + if err != nil || res.StatusCode != http.StatusOK { return builder.HeighlinerQueuedChainBuilds{}, fmt.Errorf("error performing github releases request: %v", err) } From 4575a7a63c8836d12bd9b3cf0bbe062f79e5825d Mon Sep 17 00:00:00 2001 From: vimystic <122659254+vimystic@users.noreply.github.com> Date: Thu, 27 Jul 2023 03:36:34 -0600 Subject: [PATCH 2/4] Update log message to reflect status code and message if any --- cmd/queue.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/queue.go b/cmd/queue.go index e486214..32f6be1 100644 --- a/cmd/queue.go +++ b/cmd/queue.go @@ -45,7 +45,7 @@ func mostRecentReleasesForChain( res, err := client.Do(req) if err != nil || res.StatusCode != http.StatusOK { - return builder.HeighlinerQueuedChainBuilds{}, fmt.Errorf("error performing github releases request: %v", err) + return builder.HeighlinerQueuedChainBuilds{}, fmt.Errorf("error performing github releases request: %v:%v", res.StatusCode, err) } defer res.Body.Close() From 88262a59c276943cae6e6c1479e601b165c78070 Mon Sep 17 00:00:00 2001 From: vimystic <122659254+vimystic@users.noreply.github.com> Date: Thu, 27 Jul 2023 09:30:27 -0600 Subject: [PATCH 3/4] Split err and status checks to avoid a null dereference error --- cmd/queue.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cmd/queue.go b/cmd/queue.go index 32f6be1..143f52e 100644 --- a/cmd/queue.go +++ b/cmd/queue.go @@ -44,8 +44,11 @@ func mostRecentReleasesForChain( } res, err := client.Do(req) - if err != nil || res.StatusCode != http.StatusOK { - return builder.HeighlinerQueuedChainBuilds{}, fmt.Errorf("error performing github releases request: %v:%v", res.StatusCode, err) + if err != nil { + return builder.HeighlinerQueuedChainBuilds{}, fmt.Errorf("error performing github releases request: %v", err) + } + if res.StatusCode != http.StatusOK { + return builder.HeighlinerQueuedChainBuilds{}, fmt.Errorf("status code: %v", res.StatusCode) } defer res.Body.Close() From 7449c405cc57a7d1a18f004937052e7df50be09d Mon Sep 17 00:00:00 2001 From: vimystic <122659254+vimystic@users.noreply.github.com> Date: Thu, 27 Jul 2023 09:32:42 -0600 Subject: [PATCH 4/4] Adress new line warning on gostatic check --- cmd/queue.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/queue.go b/cmd/queue.go index 143f52e..323d65e 100644 --- a/cmd/queue.go +++ b/cmd/queue.go @@ -22,7 +22,7 @@ func mostRecentReleasesForChain( number int16, ) (builder.HeighlinerQueuedChainBuilds, error) { if chainNodeConfig.GithubOrganization == "" || chainNodeConfig.GithubRepo == "" { - return builder.HeighlinerQueuedChainBuilds{}, fmt.Errorf("github organization: %s and/or repo: %s not provided for chain: %s\n", chainNodeConfig.GithubOrganization, chainNodeConfig.GithubRepo, chainNodeConfig.Name) + return builder.HeighlinerQueuedChainBuilds{}, fmt.Errorf("github organization: %s and/or repo: %s not provided for chain: %s", chainNodeConfig.GithubOrganization, chainNodeConfig.GithubRepo, chainNodeConfig.Name) } client := http.Client{Timeout: 5 * time.Second}