diff --git a/server/dbserver.go b/server/dbserver.go index 1fc7f8c1b..b30050988 100644 --- a/server/dbserver.go +++ b/server/dbserver.go @@ -18,6 +18,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" diff --git a/server/dbserver_worker_workflow.go b/server/dbserver_worker_workflow.go index 0e4bc73a3..5e5ea62cb 100644 --- a/server/dbserver_worker_workflow.go +++ b/server/dbserver_worker_workflow.go @@ -96,6 +96,11 @@ func (s *DBServer) ReportActionStatus(ctx context.Context, req *workflow.Workflo actionIndex++ } } + + if wfContext.TotalNumberOfActions > 1 && 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)