Skip to content

Commit

Permalink
Merge pull request #123 from yashsinghcodes/urgent-fix2
Browse files Browse the repository at this point in the history
quick-fix: incorrect indexing logic causing panic
  • Loading branch information
frikky authored Nov 13, 2024
2 parents 88d7494 + 29c2982 commit 089450a
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -23435,32 +23438,33 @@ 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 {
_, 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
}

Expand Down

0 comments on commit 089450a

Please sign in to comment.