Skip to content

Commit

Permalink
fix: map cast
Browse files Browse the repository at this point in the history
  • Loading branch information
Mahanmmi committed Dec 29, 2024
1 parent dc9bc39 commit 915728b
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions jobs/compliance-runner-job/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -403,14 +403,17 @@ func (w *Worker) runRegoWorkerJob(ctx context.Context, j Job, queryParamMap map[
regoResultMaps := make([]map[string]any, 0)
for _, regoResult := range regoResults {
for _, expression := range regoResult.Expressions {
if messages, ok := expression.Value.([]map[string]any); ok {
if messages, ok := expression.Value.([]any); ok {
for _, msg := range messages {
msg := msg
regoResultMaps = append(regoResultMaps, msg)
msgMap, ok := msg.(map[string]any)
if !ok {
w.logger.Error("failed to parse rego result, output is not an object", zap.Any("regoResult", expression.Value), zap.String("query_id", j.ExecutionPlan.Query.ID), zap.Stringp("integration_id", j.ExecutionPlan.IntegrationID), zap.Uint("job_id", j.ID), zap.String("type", fmt.Sprintf("%T", msg)))
return nil, fmt.Errorf("failed to parse rego result output is not an object")
}
regoResultMaps = append(regoResultMaps, msgMap)
}
} else {
w.logger.Error("failed to parse rego result, output is not a map", zap.Any("regoResult", expression.Value))
return nil, fmt.Errorf("failed to parse rego result output is not a map")

}
}
}
Expand All @@ -436,7 +439,7 @@ func (w *Worker) runRegoWorkerJob(ctx context.Context, j Job, queryParamMap map[
zap.String("query_id", j.ExecutionPlan.Query.ID),
zap.Int("result_count", len(results.Data)),
)

return &results, nil
}

Expand Down

0 comments on commit 915728b

Please sign in to comment.