Skip to content

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

fix: risk Variables name (#5220)

p0nyea11a210195a
diff --git a/backend/runner/approval/runner.go b/backend/runner/approval/runner.go
index bc64e9029c..a5421c7c79 100644
--- a/backend/runner/approval/runner.go
+++ b/backend/runner/approval/runner.go
@@ -41,7 +41,7 @@ var riskFactors = []cel.EnvOption{
}
var riskVariables = []cel.EnvOption{
- cel.Variable("risk", cel.IntType),
+ cel.Variable("level", cel.IntType),
cel.Variable("source", cel.IntType),
}
@@ -162,17 +162,17 @@ func getApprovalTemplate(approvalSetting *storepb.WorkspaceApprovalSetting, risk
return nil, err
}
for _, rule := range approvalSetting.Rules {
- if rule.Expression == nil {
+ if rule.Expression == nil || rule.Expression.Expr == nil {
continue
}
ast := cel.ParsedExprToAst(rule.Expression)
prg, err := e.Program(ast)
if err != nil {
- return nil, err
+ return nil, errors.Wrap(err, "failed to compile expression")
}
res, _, err := prg.Eval(map[string]interface{}{
- "risk": riskLevel,
+ "level": riskLevel,
"source": convertToSource(riskSource),
})
if err != nil {
@@ -308,6 +308,9 @@ func getTaskRiskLevel(ctx context.Context, s *store.Store, issue *store.IssueMes
if risk.Source != issueTypeToRiskSource[issue.Type] {
continue
}
+ if risk.Expression == nil || risk.Expression.Expr == nil {
+ continue
+ }
ast := cel.ParsedExprToAst(risk.Expression)
prg, err := e.Program(ast)