Fix retError not being returned
@@ -135,18 +135,16 @@ func (w *workflowResetorImpl) checkDomainStatus(newMutableState mutableState, pr
clusterMetadata := w.eng.shard.GetService().GetClusterMetadata()
currentVersion := newMutableState.GetCurrentVersion()
if currentVersion < prevRunVersion {
- retError = ce.NewDomainNotActiveError(
+ return ce.NewDomainNotActiveError(
domain,
clusterMetadata.GetCurrentClusterName(),
clusterMetadata.ClusterNameForFailoverVersion(prevRunVersion),
)
- return
}
activeCluster := clusterMetadata.ClusterNameForFailoverVersion(currentVersion)
currentCluster := clusterMetadata.GetCurrentClusterName()
if activeCluster != currentCluster {
- retError = ce.NewDomainNotActiveError(domain, currentCluster, activeCluster)
- return
+ return ce.NewDomainNotActiveError(domain, currentCluster, activeCluster)
}
}
return nil
@@ -154,18 +152,17 @@ func (w *workflowResetorImpl) checkDomainStatus(newMutableState mutableState, pr
func (w *workflowResetorImpl) validateResetWorkflowBeforeReplay(baseMutableState, currMutableState mutableState) (retError error) {
if baseMutableState.GetEventStoreVersion() != persistence.EventStoreVersionV2 {
- retError = &workflow.BadRequestError{
+ return &workflow.BadRequestError{
Message: fmt.Sprintf("reset API is not supported for V1 history events"),
}
- return
}
if len(currMutableState.GetPendingChildExecutionInfos()) > 0 {
- retError = &workflow.BadRequestError{
+ return &workflow.BadRequestError{
Message: fmt.Sprintf("reset is not allowed when current workflow has pending child workflow."),
}
}
if currMutableState.IsWorkflowExecutionRunning() {
- retError = &workflow.InternalServiceError{
+ return &workflow.InternalServiceError{
Message: fmt.Sprintf("current workflow should already been terminated"),
}
}
@@ -178,18 +175,17 @@ func (w *workflowResetorImpl) validateResetWorkflowAfterReplay(newMutableState m
return
}
if !newMutableState.HasInFlightDecisionTask() {
- retError = &workflow.InternalServiceError{
+ return &workflow.InternalServiceError{
Message: fmt.Sprintf("can't find the last started decision"),
}
- return
}
if newMutableState.HasBufferedEvents() {
- retError = &workflow.InternalServiceError{
+ return &workflow.InternalServiceError{
Message: fmt.Sprintf("replay history shouldn't see any bufferred events"),
}
}
if newMutableState.IsStickyTaskListEnabled() {
- retError = &workflow.InternalServiceError{
+ return &workflow.InternalServiceError{
Message: fmt.Sprintf("replay history shouldn't have stikyness"),
}
}
@@ -268,6 +264,7 @@ func (w *workflowResetorImpl) buildNewMutableStateForReset(
identityHistoryService, resetReason, baseRunID, newRunID, forkEventVersion)
if event == nil {
retError = &workflow.InternalServiceError{Message: "Failed to add decision failed event."}
+ return
}
retError = w.failStartedActivities(newMutableState)
@@ -593,6 +590,7 @@ func (w *workflowResetorImpl) replayHistoryEvents(decisionFinishEventID int64, r
retError = &workflow.BadRequestError{
Message: fmt.Sprintf("wrong DecisionFinishEventId, cannot replay history to continueAsNew"),
}
+ return
}
_, _, _, retError = sBuilder.applyEvents(domainID, requestID, prevExecution, history, nil, persistence.EventStoreVersionV2, persistence.EventStoreVersionV2)
