diff --git a/service/history/api/startworkflow/api.go b/service/history/api/startworkflow/api.go index 96db0909fe3..dc5d9b3ea6c 100644 --- a/service/history/api/startworkflow/api.go +++ b/service/history/api/startworkflow/api.go @@ -425,6 +425,8 @@ func (s *Starter) resolveDuplicateWorkflowID( ) switch { + case err != nil: + return nil, StartErr, err case errors.Is(err, api.ErrUseCurrentExecution): return s.handleUseExistingWorkflowOnConflictOptions( ctx, @@ -432,8 +434,6 @@ func (s *Starter) resolveDuplicateWorkflowID( currentWorkflowConditionFailed, currentWorkflowStartTime, ) - case err != nil: - return nil, StartErr, err case currentExecutionUpdateAction == nil: return nil, StartNew, nil } @@ -589,9 +589,7 @@ func extractMutableStateInfo(mutableState historyi.MutableState) (*mutableStateI // The workflowTask returned from the mutable state call is generated on the fly and technically doesn't require // cloning. We clone here just in case that changes. var workflowTask historyi.WorkflowTaskInfo - if workflowTaskSource != nil { - workflowTask = *workflowTaskSource - } + workflowTask = *workflowTaskSource return &mutableStateInfo{ branchToken: branchToken, @@ -610,7 +608,7 @@ func (s *Starter) getWorkflowHistory(ctx context.Context, mutableState *mutableS response, err := s.shardContext.GetExecutionManager().ReadHistoryBranch(ctx, &persistence.ReadHistoryBranchRequest{ ShardID: s.shardContext.GetShardID(), BranchToken: mutableState.branchToken, - MinEventID: 1, + MinEventID: 2, MaxEventID: mutableState.lastEventID, PageSize: 1024, }) @@ -778,7 +776,7 @@ func (s *Starter) generateResponse( // TODO: consider getting the ID from mutable state, this was not done to avoid adding more complexity to // the code to plumb that value through. PreviousStartedEventId: 0, - StartedEventId: workflowTaskInfo.StartedEventID, + StartedEventId: workflowTaskInfo.ScheduledEventID, Attempt: workflowTaskInfo.Attempt, History: &historypb.History{Events: historyEvents}, NextPageToken: nil,