From 196ecaef200310d810f1bbeb5003518b8f7af120 Mon Sep 17 00:00:00 2001 From: yashsinghcodes Date: Thu, 14 Nov 2024 00:48:13 +0530 Subject: [PATCH 1/2] quick-fix: incorrect indexing logic causing panic --- shared.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/shared.go b/shared.go index 1f4c76e..f450113 100755 --- a/shared.go +++ b/shared.go @@ -23408,10 +23408,13 @@ func CheckNextActions(ctx context.Context, workflowExecution *WorkflowExecution) } */ - for index, actionId := range nextActions { + var updatedActions []string + + for _, actionId := range nextActions { skippedParents := 0 if _, ok := parents[actionId]; !ok { + updatedActions = append(updatedActions, actionId) continue } @@ -23435,12 +23438,13 @@ func CheckNextActions(ctx context.Context, workflowExecution *WorkflowExecution) continue } - nextActions = append(nextActions[:index], nextActions[index+1:]...) } + } else { + updatedActions = append(updatedActions, actionId) } } - return nextActions + return updatedActions } func ActionSkip(ctx context.Context, foundAction Action, exec *WorkflowExecution, parent []string) error { From 29c29826c54c3373612a1abe6d1a9dc68f33bd8e Mon Sep 17 00:00:00 2001 From: yashsinghcodes Date: Thu, 14 Nov 2024 02:10:36 +0530 Subject: [PATCH 2/2] fixed result formating and return if result exist --- shared.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shared.go b/shared.go index f450113..134de87 100755 --- a/shared.go +++ b/shared.go @@ -23451,20 +23451,20 @@ func ActionSkip(ctx context.Context, foundAction Action, exec *WorkflowExecution _, actionResult := GetActionResult(ctx, *exec, foundAction.ID) if actionResult.Action.ID == foundAction.ID { log.Printf("[DEBUG][%s] Result already exist for the action %s (%s)", exec.ExecutionId, foundAction.Label, foundAction.ID) + return nil } newResult := ActionResult{ Action: foundAction, ExecutionId: exec.ExecutionId, Authorization: exec.Authorization, - Result: fmt.Sprintf(`{"success": false, "reason": "Skipped because of previous node - %d" - %v}`, len(parent), parent), + Result: fmt.Sprintf(`{"success": false, "reason": "Skipped because of previous node - %d - %v"}`, len(parent), parent), StartedAt: 0, CompletedAt: 0, Status: "SKIPPED", } resultData, err := json.Marshal(newResult) if err != nil { - log.Printf("[ERROR] Failed skipping action") return err }