Skip to content

Commit 089450a

Browse files
authored
Merge pull request #123 from yashsinghcodes/urgent-fix2
quick-fix: incorrect indexing logic causing panic
2 parents 88d7494 + 29c2982 commit 089450a

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

shared.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23408,10 +23408,13 @@ func CheckNextActions(ctx context.Context, workflowExecution *WorkflowExecution)
2340823408
}
2340923409
*/
2341023410

23411-
for index, actionId := range nextActions {
23411+
var updatedActions []string
23412+
23413+
for _, actionId := range nextActions {
2341223414
skippedParents := 0
2341323415

2341423416
if _, ok := parents[actionId]; !ok {
23417+
updatedActions = append(updatedActions, actionId)
2341523418
continue
2341623419
}
2341723420

@@ -23435,32 +23438,33 @@ func CheckNextActions(ctx context.Context, workflowExecution *WorkflowExecution)
2343523438
continue
2343623439
}
2343723440

23438-
nextActions = append(nextActions[:index], nextActions[index+1:]...)
2343923441
}
23442+
} else {
23443+
updatedActions = append(updatedActions, actionId)
2344023444
}
2344123445
}
2344223446

23443-
return nextActions
23447+
return updatedActions
2344423448
}
2344523449

2344623450
func ActionSkip(ctx context.Context, foundAction Action, exec *WorkflowExecution, parent []string) error {
2344723451
_, actionResult := GetActionResult(ctx, *exec, foundAction.ID)
2344823452
if actionResult.Action.ID == foundAction.ID {
2344923453
log.Printf("[DEBUG][%s] Result already exist for the action %s (%s)", exec.ExecutionId, foundAction.Label, foundAction.ID)
23454+
return nil
2345023455
}
2345123456

2345223457
newResult := ActionResult{
2345323458
Action: foundAction,
2345423459
ExecutionId: exec.ExecutionId,
2345523460
Authorization: exec.Authorization,
23456-
Result: fmt.Sprintf(`{"success": false, "reason": "Skipped because of previous node - %d" - %v}`, len(parent), parent),
23461+
Result: fmt.Sprintf(`{"success": false, "reason": "Skipped because of previous node - %d - %v"}`, len(parent), parent),
2345723462
StartedAt: 0,
2345823463
CompletedAt: 0,
2345923464
Status: "SKIPPED",
2346023465
}
2346123466
resultData, err := json.Marshal(newResult)
2346223467
if err != nil {
23463-
log.Printf("[ERROR] Failed skipping action")
2346423468
return err
2346523469
}
2346623470

0 commit comments

Comments
 (0)