From df404c118cecbe1f7babe0c43e5e82aa48562cf7 Mon Sep 17 00:00:00 2001 From: Lukas Hass Date: Wed, 8 Nov 2023 19:22:34 +0100 Subject: [PATCH] feat: fail enough approval check when config is invalid --- plugins/auto_merge/checks/has_enough_approvals.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plugins/auto_merge/checks/has_enough_approvals.go b/plugins/auto_merge/checks/has_enough_approvals.go index 665976c..79e45ae 100644 --- a/plugins/auto_merge/checks/has_enough_approvals.go +++ b/plugins/auto_merge/checks/has_enough_approvals.go @@ -30,6 +30,11 @@ func (check HasEnoughApprovalsCheck) Check(config *config.AutoMergeConfig, proje missingApprovalForLabels[mergeRequest.ID] = []string{} for _, neededApproval := range config.NeededApprovals { + if neededApproval.Label == "" || len(neededApproval.Users) == 0 { + log.Warn("Invalid needed approval config") + return false + } + // skip (don't require approval) if the label does not exists on the MR and the required label is not a wildcard (always check) if !utils.StringInSlice(neededApproval.Label, mergeRequest.Labels) && neededApproval.Label != "*" { continue