Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: fall through to DEFAULT risk level correctly when risks are empty (#5566)

Liu Jid32260d7b8bd
diff --git a/backend/runner/approval/runner.go b/backend/runner/approval/runner.go
index 2f1362ff07..fbc26dce7c 100644
--- a/backend/runner/approval/runner.go
+++ b/backend/runner/approval/runner.go
@@ -161,9 +161,8 @@ func (r *Runner) findApprovalTemplateForIssue(ctx context.Context, issue *store.
// no need to find if
// - feature is not enabled
// - risk source is RiskSourceUnknown
- // - risks are empty
// - approval setting rules are empty
- if !r.licenseService.IsFeatureEnabled(api.FeatureCustomApproval) || issueTypeToRiskSource[issue.Type] == store.RiskSourceUnknown || len(risks) == 0 || len(approvalSetting.Rules) == 0 {
+ if !r.licenseService.IsFeatureEnabled(api.FeatureCustomApproval) || issueTypeToRiskSource[issue.Type] == store.RiskSourceUnknown || len(approvalSetting.Rules) == 0 {
if err := updateIssuePayload(ctx, r.store, issue.UID, &storepb.IssuePayload{
Approval: &storepb.IssuePayloadApproval{
ApprovalFindingDone: true,
@@ -313,6 +312,11 @@ func getReportResult(ctx context.Context, s *store.Store, task *store.TaskMessag
}
func getTaskRiskLevel(ctx context.Context, s *store.Store, issue *store.IssueMessage, task *store.TaskMessage, risks []*store.RiskMessage) (int64, bool, error) {
+ // Fall through to "DEFAULT" risk level if risks are empty.
+ if len(risks) == 0 {
+ return 0, true, nil
+ }
+
instance, err := s.GetInstanceV2(ctx, &store.FindInstanceMessage{
UID: &task.InstanceID,
})