Skip to content

Commit

Permalink
error rather than panic when workflow action index is invalid
Browse files Browse the repository at this point in the history
Signed-off-by: Marques Johansson <[email protected]>
  • Loading branch information
displague committed Jan 12, 2022
1 parent b18b238 commit 6c0f5f6
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions grpc-server/tinkerbell.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const (
errInvalidActionName = "invalid action name"
errInvalidTaskReported = "reported task name does not match the current action details"
errInvalidActionReported = "reported action name does not match the current action details"
errInvalidActionIndex = "invalid action index for workflow"

msgReceivedStatus = "received action status: %s"
msgCurrentWfContext = "current workflow context"
Expand Down Expand Up @@ -111,6 +112,9 @@ func (s *server) ReportActionStatus(ctx context.Context, req *pb.WorkflowActionS
actionIndex++
}
}
if actionIndex == wfContext.TotalNumberOfActions-1 {
return nil, status.Errorf(codes.FailedPrecondition, errInvalidActionIndex)
}
action := wfActions.ActionList[actionIndex]
if action.GetTaskName() != req.GetTaskName() {
return nil, status.Errorf(codes.InvalidArgument, errInvalidTaskReported)
Expand Down

0 comments on commit 6c0f5f6

Please sign in to comment.