From 34ff13984ad7853eb812d65e98ec01c1eff33309 Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Mon, 27 Jun 2022 10:14:58 +0200 Subject: [PATCH] ci: prevent panic in retest action on `nil` strings In case a PullRequest does not have a MergeableState set, it will be `nil`. Dereferencing the pointer will cause a Go panic, and the action won't work as intended. Signed-off-by: Niels de Vos --- actions/retest/main.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/actions/retest/main.go b/actions/retest/main.go index 075cea7e3..26ef0b610 100644 --- a/actions/retest/main.go +++ b/actions/retest/main.go @@ -116,7 +116,7 @@ func main() { log.Fatalf("failed to list pull requests %v\n", err) } for _, re := range req { - if *re.State == "open" { + if (re.State != nil) && (*re.State == "open") { prNumber := re.GetNumber() log.Printf("PR with ID %d with Title %q is open\n", prNumber, re.GetTitle()) for _, l := range re.Labels { @@ -149,7 +149,7 @@ func main() { log.Printf("found failed test %s\n", r.GetContext()) failedTestFound = true // rebase the pr if it is behind the devel branch. - if *re.MergeableState == "BEHIND" { + if (re.MergeableState != nil) && (*re.MergeableState == "BEHIND") { comment := &github.IssueComment{ Body: github.String("@mergifyio rebase"), }