From 0344f52d6f46985f9f4959bd9b60693235c9bccd Mon Sep 17 00:00:00 2001 From: Andreas Brehmer <38314220+anbrsap@users.noreply.github.com> Date: Fri, 16 Jun 2023 13:39:29 +0200 Subject: [PATCH] Fix: Error cause is missing (#7563) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Include the message of an error happening during mutation of elements of a `foreach` loop. Signed-off-by: Andreas Brehmer Co-authored-by: Charles-Edouard Brétéché --- pkg/engine/handlers/mutation/common.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/engine/handlers/mutation/common.go b/pkg/engine/handlers/mutation/common.go index 5ead15919d..b2cc5c66d5 100644 --- a/pkg/engine/handlers/mutation/common.go +++ b/pkg/engine/handlers/mutation/common.go @@ -2,6 +2,7 @@ package mutation import ( "context" + "errors" "fmt" "github.com/go-logr/logr" @@ -36,7 +37,7 @@ func (f *forEachMutator) mutateForEach(ctx context.Context) *mutate.Response { mutateResp := f.mutateElements(ctx, foreach, elements) if mutateResp.Status == engineapi.RuleStatusError { - return mutate.NewErrorResponse("failed to mutate elements", err) + return mutate.NewErrorResponse("failed to mutate elements", errors.New(mutateResp.Message)) } if mutateResp.Status != engineapi.RuleStatusSkip {