From 72a87afee6a9f202f35b4b8b7e63ca907d2d1612 Mon Sep 17 00:00:00 2001 From: Bowei Xu Date: Thu, 29 Mar 2018 16:05:38 -0700 Subject: [PATCH 1/4] use get func instead of dereference --- service/frontend/handler.go | 24 ++++++++++++------------ service/history/handler.go | 6 +++--- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/service/frontend/handler.go b/service/frontend/handler.go index b02818ef54d..bb92fbce279 100644 --- a/service/frontend/handler.go +++ b/service/frontend/handler.go @@ -276,7 +276,7 @@ func (wh *WorkflowHandler) DescribeDomain(ctx context.Context, } resp, err := wh.metadataMgr.GetDomain(&persistence.GetDomainRequest{ - Name: *describeRequest.Name, + Name: describeRequest.GetName(), }) if err != nil { @@ -554,7 +554,7 @@ func (wh *WorkflowHandler) PollForActivityTask( if err != nil { // For all other errors log an error and return it back to client. wh.Service.GetLogger().Errorf( - "PollForActivityTask failed. TaskList: %v, Error: %v", *pollRequest.TaskList.Name, err) + "PollForActivityTask failed. TaskList: %v, Error: %v", pollRequest.TaskList.GetName(), err) return nil, wh.error(err, scope) } } @@ -609,7 +609,7 @@ func (wh *WorkflowHandler) PollForDecisionTask( if err != nil { // For all other errors log an error and return it back to client. wh.Service.GetLogger().Errorf( - "PollForDecisionTask failed. TaskList: %v, Error: %v", *pollRequest.TaskList.Name, err) + "PollForDecisionTask failed. TaskList: %v, Error: %v", pollRequest.TaskList.GetName(), err) return nil, wh.error(err, scope) } @@ -1142,7 +1142,7 @@ func (wh *WorkflowHandler) StartWorkflowExecution( wh.Service.GetLogger().Debugf( "Received StartWorkflowExecution. WorkflowID: %v", - *startRequest.WorkflowId) + startRequest.GetWorkflowId()) if startRequest.WorkflowType == nil || startRequest.WorkflowType.Name == nil || *startRequest.WorkflowType.Name == "" { @@ -1154,13 +1154,13 @@ func (wh *WorkflowHandler) StartWorkflowExecution( } if startRequest.ExecutionStartToCloseTimeoutSeconds == nil || - *startRequest.ExecutionStartToCloseTimeoutSeconds <= 0 { + startRequest.GetExecutionStartToCloseTimeoutSeconds() <= 0 { return nil, wh.error(&gen.BadRequestError{ Message: "A valid ExecutionStartToCloseTimeoutSeconds is not set on request."}, scope) } if startRequest.TaskStartToCloseTimeoutSeconds == nil || - *startRequest.TaskStartToCloseTimeoutSeconds <= 0 { + startRequest.GetTaskStartToCloseTimeoutSeconds() <= 0 { return nil, wh.error(&gen.BadRequestError{ Message: "A valid TaskStartToCloseTimeoutSeconds is not set on request."}, scope) } @@ -1205,7 +1205,7 @@ func (wh *WorkflowHandler) GetWorkflowExecutionHistory( return nil, err } - if getRequest.MaximumPageSize == nil || *getRequest.MaximumPageSize == 0 { + if getRequest.MaximumPageSize == nil || getRequest.GetMaximumPageSize() == 0 { getRequest.MaximumPageSize = common.Int32Ptr(wh.config.DefaultHistoryMaxPageSize) } @@ -1250,7 +1250,7 @@ func (wh *WorkflowHandler) GetWorkflowExecutionHistory( if err != nil { return nil, wh.error(errInvalidNextPageToken, scope) } - if execution.RunId != nil && *execution.RunId != token.RunID { + if execution.RunId != nil && execution.GetRunId() != token.RunID { return nil, wh.error(errNextPageTokenRunIDMismatch, scope) } @@ -1317,7 +1317,7 @@ func (wh *WorkflowHandler) GetWorkflowExecutionHistory( } else { history, token.PersistenceToken, err = wh.getHistory(domainID, *execution, token.FirstEventID, token.NextEventID, - *getRequest.MaximumPageSize, token.PersistenceToken, token.TransientDecision) + getRequest.GetMaximumPageSize(), token.PersistenceToken, token.TransientDecision) if err != nil { return nil, wh.error(err, scope) } @@ -1550,7 +1550,7 @@ func (wh *WorkflowHandler) ListOpenWorkflowExecutions(ctx context.Context, Message: "Only one of ExecutionFilter or TypeFilter is allowed"}, scope) } - if listRequest.MaximumPageSize == nil || *listRequest.MaximumPageSize == 0 { + if listRequest.MaximumPageSize == nil || listRequest.GetMaximumPageSize() == 0 { listRequest.MaximumPageSize = common.Int32Ptr(wh.config.DefaultVisibilityMaxPageSize) } @@ -1637,7 +1637,7 @@ func (wh *WorkflowHandler) ListClosedWorkflowExecutions(ctx context.Context, Message: "Only one of ExecutionFilter, TypeFilter or StatusFilter is allowed"}, scope) } - if listRequest.MaximumPageSize == nil || *listRequest.MaximumPageSize == 0 { + if listRequest.MaximumPageSize == nil || listRequest.GetMaximumPageSize() == 0 { listRequest.MaximumPageSize = common.Int32Ptr(wh.config.DefaultVisibilityMaxPageSize) } @@ -1971,7 +1971,7 @@ func (wh *WorkflowHandler) validateTaskListType(t *gen.TaskListType, scope int) } func (wh *WorkflowHandler) validateTaskList(t *gen.TaskList, scope int) error { - if t == nil || t.Name == nil || *t.Name == "" { + if t == nil || t.Name == nil || t.GetName() == "" { return wh.error(errTaskListNotSet, scope) } return nil diff --git a/service/history/handler.go b/service/history/handler.go index 1c5478a1841..b61adb6f56f 100644 --- a/service/history/handler.go +++ b/service/history/handler.go @@ -230,8 +230,8 @@ func (h *Handler) RecordDecisionTaskStarted(ctx context.Context, recordRequest *hist.RecordDecisionTaskStartedRequest) (*hist.RecordDecisionTaskStartedResponse, error) { h.startWG.Wait() h.Service.GetLogger().Debugf("RecordDecisionTaskStarted. DomainID: %v, WorkflowID: %v, RunID: %v, ScheduleID: %v", - *recordRequest.DomainUUID, *recordRequest.WorkflowExecution.WorkflowId, - common.StringDefault(recordRequest.WorkflowExecution.RunId), *recordRequest.ScheduleId) + recordRequest.GetDomainUUID(), recordRequest.WorkflowExecution.GetWorkflowId(), + common.StringDefault(recordRequest.WorkflowExecution.RunId), recordRequest.GetScheduleId()) h.metricsClient.IncCounter(metrics.HistoryRecordDecisionTaskStartedScope, metrics.CadenceRequests) sw := h.metricsClient.StartTimer(metrics.HistoryRecordDecisionTaskStartedScope, metrics.CadenceLatency) @@ -721,7 +721,7 @@ func (h *Handler) ScheduleDecisionTask(ctx context.Context, request *hist.Schedu } workflowExecution := request.WorkflowExecution - engine, err1 := h.controller.GetEngine(*workflowExecution.WorkflowId) + engine, err1 := h.controller.GetEngine(workflowExecution.GetWorkflowId()) if err1 != nil { h.updateErrorMetric(metrics.HistoryScheduleDecisionTaskScope, err1) return err1 From 8da5448b1d7eca2d70d7bc1ada9aad877cf05c4f Mon Sep 17 00:00:00 2001 From: Bowei Xu Date: Thu, 29 Mar 2018 16:12:30 -0700 Subject: [PATCH 2/4] fix queryWorkflow emptu runID check --- service/frontend/handler.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/service/frontend/handler.go b/service/frontend/handler.go index bb92fbce279..46ffa046dcb 100644 --- a/service/frontend/handler.go +++ b/service/frontend/handler.go @@ -1701,12 +1701,8 @@ func (wh *WorkflowHandler) QueryWorkflow(ctx context.Context, return nil, wh.error(errExecutionNotSet, scope) } - if queryRequest.Execution.WorkflowId == nil { - return nil, wh.error(errWorkflowIDNotSet, scope) - } - - if queryRequest.Execution.RunId != nil && uuid.Parse(queryRequest.Execution.GetRunId()) == nil { - return nil, wh.error(errInvalidRunID, scope) + if err := wh.validateExecution(queryRequest.Execution, scope); err != nil { + return nil, err } if queryRequest.Query == nil { From b783f631bff7ef87d1eab2ce04fc8eb4f5b103ea Mon Sep 17 00:00:00 2001 From: Bowei Xu Date: Thu, 29 Mar 2018 16:27:56 -0700 Subject: [PATCH 3/4] check nil for all requests --- service/frontend/handler.go | 115 +++++++++++++++++++++++++++++++++++- 1 file changed, 114 insertions(+), 1 deletion(-) diff --git a/service/frontend/handler.go b/service/frontend/handler.go index 46ffa046dcb..14000f9a36d 100644 --- a/service/frontend/handler.go +++ b/service/frontend/handler.go @@ -99,6 +99,7 @@ var ( errNextPageTokenRunIDMismatch = &gen.BadRequestError{Message: "RunID in the request does not match the NextPageToken."} errQueryNotSet = &gen.BadRequestError{Message: "WorkflowQuery is not set on request."} errQueryTypeNotSet = &gen.BadRequestError{Message: "QueryType is not set on request."} + errRequestNotSet = &gen.BadRequestError{Message: "Request is nil."} // err indicating that this cluster is not the master, so cannot do domain registration or update errNotMasterCluster = &gen.BadRequestError{Message: "Cluster is not master cluster, cannot do domain registration or domain update."} @@ -172,11 +173,14 @@ func (wh *WorkflowHandler) Health(ctx context.Context) (*health.HealthStatus, er // acts as a sandbox and provides isolation for all resources within the domain. All resources belongs to exactly one // domain. func (wh *WorkflowHandler) RegisterDomain(ctx context.Context, registerRequest *gen.RegisterDomainRequest) error { - scope := metrics.FrontendRegisterDomainScope sw := wh.startRequestProfile(scope) defer sw.Stop() + if registerRequest == nil { + return wh.error(errRequestNotSet, scope) + } + clusterMetadata := wh.GetClusterMetadata() // TODO remove the IsGlobalDomainEnabled check once cross DC is public if clusterMetadata.IsGlobalDomainEnabled() && !clusterMetadata.IsMasterCluster() { @@ -271,6 +275,10 @@ func (wh *WorkflowHandler) DescribeDomain(ctx context.Context, sw := wh.startRequestProfile(scope) defer sw.Stop() + if describeRequest == nil { + return nil, wh.error(errRequestNotSet, scope) + } + if describeRequest.Name == nil { return nil, wh.error(errDomainNotSet, scope) } @@ -301,6 +309,10 @@ func (wh *WorkflowHandler) UpdateDomain(ctx context.Context, sw := wh.startRequestProfile(scope) defer sw.Stop() + if updateRequest == nil { + return nil, wh.error(errRequestNotSet, scope) + } + clusterMetadata := wh.GetClusterMetadata() // TODO remove the IsGlobalDomainEnabled check once cross DC is public if !clusterMetadata.IsGlobalDomainEnabled() { @@ -475,6 +487,10 @@ func (wh *WorkflowHandler) DeprecateDomain(ctx context.Context, deprecateRequest sw := wh.startRequestProfile(scope) defer sw.Stop() + if deprecateRequest == nil { + return wh.error(errRequestNotSet, scope) + } + clusterMetadata := wh.GetClusterMetadata() // TODO remove the IsGlobalDomainEnabled check once cross DC is public if clusterMetadata.IsGlobalDomainEnabled() && !clusterMetadata.IsMasterCluster() { @@ -518,6 +534,10 @@ func (wh *WorkflowHandler) PollForActivityTask( sw := wh.startRequestProfile(scope) defer sw.Stop() + if pollRequest == nil { + return nil, wh.error(errRequestNotSet, scope) + } + if ok, _ := wh.rateLimiter.TryConsume(1); !ok { return nil, wh.error(createServiceBusyError(), scope) } @@ -570,6 +590,10 @@ func (wh *WorkflowHandler) PollForDecisionTask( sw := wh.startRequestProfile(scope) defer sw.Stop() + if pollRequest == nil { + return nil, wh.error(errRequestNotSet, scope) + } + if ok, _ := wh.rateLimiter.TryConsume(1); !ok { return nil, wh.error(createServiceBusyError(), scope) } @@ -658,6 +682,10 @@ func (wh *WorkflowHandler) RecordActivityTaskHeartbeat( sw := wh.startRequestProfile(scope) defer sw.Stop() + if heartbeatRequest == nil { + return nil, wh.error(errRequestNotSet, scope) + } + // Count the request in the RPS, but we still accept it even if RPS is exceeded wh.rateLimiter.TryConsume(1) @@ -692,6 +720,10 @@ func (wh *WorkflowHandler) RecordActivityTaskHeartbeatByID( sw := wh.startRequestProfile(scope) defer sw.Stop() + if heartbeatRequest == nil { + return nil, wh.error(errRequestNotSet, scope) + } + // Count the request in the RPS, but we still accept it even if RPS is exceeded wh.rateLimiter.TryConsume(1) @@ -751,6 +783,10 @@ func (wh *WorkflowHandler) RespondActivityTaskCompleted( sw := wh.startRequestProfile(scope) defer sw.Stop() + if completeRequest == nil { + return wh.error(errRequestNotSet, scope) + } + // Count the request in the RPS, but we still accept it even if RPS is exceeded wh.rateLimiter.TryConsume(1) @@ -784,6 +820,10 @@ func (wh *WorkflowHandler) RespondActivityTaskCompletedByID( sw := wh.startRequestProfile(scope) defer sw.Stop() + if completeRequest == nil { + return wh.error(errRequestNotSet, scope) + } + // Count the request in the RPS, but we still accept it even if RPS is exceeded wh.rateLimiter.TryConsume(1) @@ -842,6 +882,10 @@ func (wh *WorkflowHandler) RespondActivityTaskFailed( sw := wh.startRequestProfile(scope) defer sw.Stop() + if failedRequest == nil { + return wh.error(errRequestNotSet, scope) + } + // Count the request in the RPS, but we still accept it even if RPS is exceeded wh.rateLimiter.TryConsume(1) @@ -875,6 +919,10 @@ func (wh *WorkflowHandler) RespondActivityTaskFailedByID( sw := wh.startRequestProfile(scope) defer sw.Stop() + if failedRequest == nil { + return wh.error(errRequestNotSet, scope) + } + // Count the request in the RPS, but we still accept it even if RPS is exceeded wh.rateLimiter.TryConsume(1) @@ -934,6 +982,10 @@ func (wh *WorkflowHandler) RespondActivityTaskCanceled( sw := wh.startRequestProfile(scope) defer sw.Stop() + if cancelRequest == nil { + return wh.error(errRequestNotSet, scope) + } + // Count the request in the RPS, but we still accept it even if RPS is exceeded wh.rateLimiter.TryConsume(1) @@ -967,6 +1019,10 @@ func (wh *WorkflowHandler) RespondActivityTaskCanceledByID( sw := wh.startRequestProfile(scope) defer sw.Stop() + if cancelRequest == nil { + return wh.error(errRequestNotSet, scope) + } + // Count the request in the RPS, but we still accept it even if RPS is exceeded wh.rateLimiter.TryConsume(1) @@ -1025,6 +1081,10 @@ func (wh *WorkflowHandler) RespondDecisionTaskCompleted( sw := wh.startRequestProfile(scope) defer sw.Stop() + if completeRequest == nil { + return wh.error(errRequestNotSet, scope) + } + // Count the request in the RPS, but we still accept it even if RPS is exceeded wh.rateLimiter.TryConsume(1) @@ -1058,6 +1118,10 @@ func (wh *WorkflowHandler) RespondDecisionTaskFailed( sw := wh.startRequestProfile(scope) defer sw.Stop() + if failedRequest == nil { + return wh.error(errRequestNotSet, scope) + } + // Count the request in the RPS, but we still accept it even if RPS is exceeded wh.rateLimiter.TryConsume(1) @@ -1091,6 +1155,10 @@ func (wh *WorkflowHandler) RespondQueryTaskCompleted( sw := wh.startRequestProfile(scope) defer sw.Stop() + if completeRequest == nil { + return wh.error(errRequestNotSet, scope) + } + // Count the request in the RPS, but we still accept it even if RPS is exceeded wh.rateLimiter.TryConsume(1) @@ -1128,6 +1196,10 @@ func (wh *WorkflowHandler) StartWorkflowExecution( sw := wh.startRequestProfile(scope) defer sw.Stop() + if startRequest == nil { + return nil, wh.error(errRequestNotSet, scope) + } + if ok, _ := wh.rateLimiter.TryConsume(1); !ok { return nil, wh.error(createServiceBusyError(), scope) } @@ -1193,6 +1265,10 @@ func (wh *WorkflowHandler) GetWorkflowExecutionHistory( sw := wh.startRequestProfile(scope) defer sw.Stop() + if getRequest == nil { + return nil, wh.error(errRequestNotSet, scope) + } + if ok, _ := wh.rateLimiter.TryConsume(1); !ok { return nil, wh.error(createServiceBusyError(), scope) } @@ -1347,6 +1423,10 @@ func (wh *WorkflowHandler) SignalWorkflowExecution(ctx context.Context, sw := wh.startRequestProfile(scope) defer sw.Stop() + if signalRequest == nil { + return wh.error(errRequestNotSet, scope) + } + if ok, _ := wh.rateLimiter.TryConsume(1); !ok { return wh.error(createServiceBusyError(), scope) } @@ -1386,10 +1466,15 @@ func (wh *WorkflowHandler) SignalWorkflowExecution(ctx context.Context, // event recorded in history, and a decision task being created for the execution func (wh *WorkflowHandler) SignalWithStartWorkflowExecution(ctx context.Context, signalWithStartRequest *gen.SignalWithStartWorkflowExecutionRequest) (*gen.StartWorkflowExecutionResponse, error) { + scope := metrics.FrontendSignalWithStartWorkflowExecutionScope sw := wh.startRequestProfile(scope) defer sw.Stop() + if signalWithStartRequest == nil { + return nil, wh.error(errRequestNotSet, scope) + } + if ok, _ := wh.rateLimiter.TryConsume(1); !ok { return nil, wh.error(createServiceBusyError(), scope) } @@ -1452,6 +1537,10 @@ func (wh *WorkflowHandler) TerminateWorkflowExecution(ctx context.Context, sw := wh.startRequestProfile(scope) defer sw.Stop() + if terminateRequest == nil { + return wh.error(errRequestNotSet, scope) + } + if ok, _ := wh.rateLimiter.TryConsume(1); !ok { return wh.error(createServiceBusyError(), scope) } @@ -1489,6 +1578,10 @@ func (wh *WorkflowHandler) RequestCancelWorkflowExecution( sw := wh.startRequestProfile(scope) defer sw.Stop() + if cancelRequest == nil { + return wh.error(errRequestNotSet, scope) + } + if ok, _ := wh.rateLimiter.TryConsume(1); !ok { return wh.error(createServiceBusyError(), scope) } @@ -1525,6 +1618,10 @@ func (wh *WorkflowHandler) ListOpenWorkflowExecutions(ctx context.Context, sw := wh.startRequestProfile(scope) defer sw.Stop() + if listRequest == nil { + return nil, wh.error(errRequestNotSet, scope) + } + if ok, _ := wh.rateLimiter.TryConsume(1); !ok { return nil, wh.error(createServiceBusyError(), scope) } @@ -1601,6 +1698,10 @@ func (wh *WorkflowHandler) ListClosedWorkflowExecutions(ctx context.Context, sw := wh.startRequestProfile(scope) defer sw.Stop() + if listRequest == nil { + return nil, wh.error(errRequestNotSet, scope) + } + if ok, _ := wh.rateLimiter.TryConsume(1); !ok { return nil, wh.error(createServiceBusyError(), scope) } @@ -1693,6 +1794,10 @@ func (wh *WorkflowHandler) QueryWorkflow(ctx context.Context, sw := wh.startRequestProfile(scope) defer sw.Stop() + if queryRequest == nil { + return nil, wh.error(errRequestNotSet, scope) + } + if queryRequest.Domain == nil { return nil, wh.error(errDomainNotSet, scope) } @@ -1790,6 +1895,10 @@ func (wh *WorkflowHandler) DescribeWorkflowExecution(ctx context.Context, reques sw := wh.startRequestProfile(scope) defer sw.Stop() + if request == nil { + return nil, wh.error(errRequestNotSet, scope) + } + if ok, _ := wh.rateLimiter.TryConsume(1); !ok { return nil, wh.error(createServiceBusyError(), scope) } @@ -1826,6 +1935,10 @@ func (wh *WorkflowHandler) DescribeTaskList(ctx context.Context, request *gen.De sw := wh.startRequestProfile(scope) defer sw.Stop() + if request == nil { + return nil, wh.error(errRequestNotSet, scope) + } + if ok, _ := wh.rateLimiter.TryConsume(1); !ok { return nil, wh.error(createServiceBusyError(), scope) } From e3a11d01e6ad6b0f44f6103c3a9855f23f52238f Mon Sep 17 00:00:00 2001 From: Bowei Xu Date: Thu, 29 Mar 2018 17:13:09 -0700 Subject: [PATCH 4/4] check domain and others be not nil and empty --- common/cache/domainCache.go | 6 +++ service/frontend/handler.go | 80 ++++++++++++++++--------------------- 2 files changed, 41 insertions(+), 45 deletions(-) diff --git a/common/cache/domainCache.go b/common/cache/domainCache.go index d040f48fbe0..f5c33b8bc51 100644 --- a/common/cache/domainCache.go +++ b/common/cache/domainCache.go @@ -98,12 +98,18 @@ func newDomainCacheEntry() *domainCacheEntry { // GetDomain retrieves the information from the cache if it exists, otherwise retrieves the information from metadata // store and writes it to the cache with an expiry before returning back func (c *domainCache) GetDomain(name string) (*domainCacheEntry, error) { + if name == "" { + return nil, &workflow.BadRequestError{Message: "Domain is empty."} + } return c.getDomain(name, "", name, c.cacheByName) } // GetDomainByID retrieves the information from the cache if it exists, otherwise retrieves the information from metadata // store and writes it to the cache with an expiry before returning back func (c *domainCache) GetDomainByID(id string) (*domainCacheEntry, error) { + if id == "" { + return nil, &workflow.BadRequestError{Message: "DomainID is empty."} + } return c.getDomain(id, id, "", c.cacheByID) } diff --git a/service/frontend/handler.go b/service/frontend/handler.go index 14000f9a36d..8c30810017a 100644 --- a/service/frontend/handler.go +++ b/service/frontend/handler.go @@ -191,7 +191,7 @@ func (wh *WorkflowHandler) RegisterDomain(ctx context.Context, registerRequest * registerRequest.Clusters = nil } - if len(registerRequest.GetName()) == 0 { + if registerRequest.GetName() == "" { return wh.error(errDomainNotSet, scope) } @@ -279,7 +279,7 @@ func (wh *WorkflowHandler) DescribeDomain(ctx context.Context, return nil, wh.error(errRequestNotSet, scope) } - if describeRequest.Name == nil { + if describeRequest.GetName() == "" { return nil, wh.error(errDomainNotSet, scope) } @@ -319,12 +319,12 @@ func (wh *WorkflowHandler) UpdateDomain(ctx context.Context, updateRequest.ReplicationConfiguration = nil } - if updateRequest.Name == nil { + if updateRequest.GetName() == "" { return nil, wh.error(errDomainNotSet, scope) } getResponse, err0 := wh.metadataMgr.GetDomain(&persistence.GetDomainRequest{ - Name: *updateRequest.Name, + Name: updateRequest.GetName(), }) if err0 != nil { @@ -497,7 +497,7 @@ func (wh *WorkflowHandler) DeprecateDomain(ctx context.Context, deprecateRequest return wh.error(errNotMasterCluster, scope) } - if deprecateRequest.Name == nil { + if deprecateRequest.GetName() == "" { return wh.error(errDomainNotSet, scope) } @@ -1204,11 +1204,11 @@ func (wh *WorkflowHandler) StartWorkflowExecution( return nil, wh.error(createServiceBusyError(), scope) } - if startRequest.Domain == nil || startRequest.GetDomain() == "" { + if startRequest.GetDomain() == "" { return nil, wh.error(errDomainNotSet, scope) } - if startRequest.WorkflowId == nil || startRequest.GetWorkflowId() == "" { + if startRequest.GetWorkflowId() == "" { return nil, wh.error(&gen.BadRequestError{Message: "WorkflowId is not set on request."}, scope) } @@ -1216,8 +1216,7 @@ func (wh *WorkflowHandler) StartWorkflowExecution( "Received StartWorkflowExecution. WorkflowID: %v", startRequest.GetWorkflowId()) - if startRequest.WorkflowType == nil || - startRequest.WorkflowType.Name == nil || *startRequest.WorkflowType.Name == "" { + if startRequest.WorkflowType == nil || startRequest.WorkflowType.GetName() == "" { return nil, wh.error(&gen.BadRequestError{Message: "WorkflowType is not set on request."}, scope) } @@ -1225,14 +1224,12 @@ func (wh *WorkflowHandler) StartWorkflowExecution( return nil, err } - if startRequest.ExecutionStartToCloseTimeoutSeconds == nil || - startRequest.GetExecutionStartToCloseTimeoutSeconds() <= 0 { + if startRequest.GetExecutionStartToCloseTimeoutSeconds() <= 0 { return nil, wh.error(&gen.BadRequestError{ Message: "A valid ExecutionStartToCloseTimeoutSeconds is not set on request."}, scope) } - if startRequest.TaskStartToCloseTimeoutSeconds == nil || - startRequest.GetTaskStartToCloseTimeoutSeconds() <= 0 { + if startRequest.GetTaskStartToCloseTimeoutSeconds() <= 0 { return nil, wh.error(&gen.BadRequestError{ Message: "A valid TaskStartToCloseTimeoutSeconds is not set on request."}, scope) } @@ -1273,7 +1270,7 @@ func (wh *WorkflowHandler) GetWorkflowExecutionHistory( return nil, wh.error(createServiceBusyError(), scope) } - if getRequest.Domain == nil { + if getRequest.GetDomain() == "" { return nil, wh.error(errDomainNotSet, scope) } @@ -1281,7 +1278,7 @@ func (wh *WorkflowHandler) GetWorkflowExecutionHistory( return nil, err } - if getRequest.MaximumPageSize == nil || getRequest.GetMaximumPageSize() == 0 { + if getRequest.GetMaximumPageSize() == 0 { getRequest.MaximumPageSize = common.Int32Ptr(wh.config.DefaultHistoryMaxPageSize) } @@ -1369,7 +1366,7 @@ func (wh *WorkflowHandler) GetWorkflowExecutionHistory( if isCloseEventOnly { if !isWorkflowRunning { history, _, err = wh.getHistory(domainID, *execution, lastFirstEventID, nextEventID, - *getRequest.MaximumPageSize, nil, token.TransientDecision) + getRequest.GetMaximumPageSize(), nil, token.TransientDecision) if err != nil { return nil, wh.error(err, scope) } @@ -1431,7 +1428,7 @@ func (wh *WorkflowHandler) SignalWorkflowExecution(ctx context.Context, return wh.error(createServiceBusyError(), scope) } - if signalRequest.Domain == nil || signalRequest.GetDomain() == "" { + if signalRequest.GetDomain() == "" { return wh.error(errDomainNotSet, scope) } @@ -1439,7 +1436,7 @@ func (wh *WorkflowHandler) SignalWorkflowExecution(ctx context.Context, return err } - if signalRequest.SignalName == nil || signalRequest.GetSignalName() == "" { + if signalRequest.GetSignalName() == "" { return wh.error(&gen.BadRequestError{Message: "SignalName is not set on request."}, scope) } @@ -1479,20 +1476,19 @@ func (wh *WorkflowHandler) SignalWithStartWorkflowExecution(ctx context.Context, return nil, wh.error(createServiceBusyError(), scope) } - if signalWithStartRequest.Domain == nil || signalWithStartRequest.GetDomain() == "" { + if signalWithStartRequest.GetDomain() == "" { return nil, wh.error(errDomainNotSet, scope) } - if signalWithStartRequest.WorkflowId == nil || signalWithStartRequest.GetWorkflowId() == "" { + if signalWithStartRequest.GetWorkflowId() == "" { return nil, wh.error(&gen.BadRequestError{Message: "WorkflowId is not set on request."}, scope) } - if signalWithStartRequest.SignalName == nil || signalWithStartRequest.GetSignalName() == "" { + if signalWithStartRequest.GetSignalName() == "" { return nil, wh.error(&gen.BadRequestError{Message: "SignalName is not set on request."}, scope) } - if signalWithStartRequest.WorkflowType == nil || - signalWithStartRequest.WorkflowType.Name == nil || signalWithStartRequest.WorkflowType.GetName() == "" { + if signalWithStartRequest.WorkflowType == nil || signalWithStartRequest.WorkflowType.GetName() == "" { return nil, wh.error(&gen.BadRequestError{Message: "WorkflowType is not set on request."}, scope) } @@ -1500,14 +1496,12 @@ func (wh *WorkflowHandler) SignalWithStartWorkflowExecution(ctx context.Context, return nil, err } - if signalWithStartRequest.ExecutionStartToCloseTimeoutSeconds == nil || - signalWithStartRequest.GetExecutionStartToCloseTimeoutSeconds() <= 0 { + if signalWithStartRequest.GetExecutionStartToCloseTimeoutSeconds() <= 0 { return nil, wh.error(&gen.BadRequestError{ Message: "A valid ExecutionStartToCloseTimeoutSeconds is not set on request."}, scope) } - if signalWithStartRequest.TaskStartToCloseTimeoutSeconds == nil || - signalWithStartRequest.GetTaskStartToCloseTimeoutSeconds() <= 0 { + if signalWithStartRequest.GetTaskStartToCloseTimeoutSeconds() <= 0 { return nil, wh.error(&gen.BadRequestError{ Message: "A valid TaskStartToCloseTimeoutSeconds is not set on request."}, scope) } @@ -1545,7 +1539,7 @@ func (wh *WorkflowHandler) TerminateWorkflowExecution(ctx context.Context, return wh.error(createServiceBusyError(), scope) } - if terminateRequest.Domain == nil { + if terminateRequest.GetDomain() == "" { return wh.error(errDomainNotSet, scope) } @@ -1586,7 +1580,7 @@ func (wh *WorkflowHandler) RequestCancelWorkflowExecution( return wh.error(createServiceBusyError(), scope) } - if cancelRequest.Domain == nil { + if cancelRequest.GetDomain() == "" { return wh.error(errDomainNotSet, scope) } @@ -1626,7 +1620,7 @@ func (wh *WorkflowHandler) ListOpenWorkflowExecutions(ctx context.Context, return nil, wh.error(createServiceBusyError(), scope) } - if listRequest.Domain == nil { + if listRequest.GetDomain() == "" { return nil, wh.error(errDomainNotSet, scope) } @@ -1634,11 +1628,11 @@ func (wh *WorkflowHandler) ListOpenWorkflowExecutions(ctx context.Context, return nil, wh.error(&gen.BadRequestError{Message: "StartTimeFilter is required"}, scope) } - if listRequest.StartTimeFilter.EarliestTime == nil { + if listRequest.StartTimeFilter.GetEarliestTime() == 0 { return nil, wh.error(&gen.BadRequestError{Message: "EarliestTime in StartTimeFilter is required"}, scope) } - if listRequest.StartTimeFilter.LatestTime == nil { + if listRequest.StartTimeFilter.GetLatestTime() == 0 { return nil, wh.error(&gen.BadRequestError{Message: "LatestTime in StartTimeFilter is required"}, scope) } @@ -1647,7 +1641,7 @@ func (wh *WorkflowHandler) ListOpenWorkflowExecutions(ctx context.Context, Message: "Only one of ExecutionFilter or TypeFilter is allowed"}, scope) } - if listRequest.MaximumPageSize == nil || listRequest.GetMaximumPageSize() == 0 { + if listRequest.GetMaximumPageSize() == 0 { listRequest.MaximumPageSize = common.Int32Ptr(wh.config.DefaultVisibilityMaxPageSize) } @@ -1706,7 +1700,7 @@ func (wh *WorkflowHandler) ListClosedWorkflowExecutions(ctx context.Context, return nil, wh.error(createServiceBusyError(), scope) } - if listRequest.Domain == nil { + if listRequest.GetDomain() == "" { return nil, wh.error(errDomainNotSet, scope) } @@ -1714,11 +1708,11 @@ func (wh *WorkflowHandler) ListClosedWorkflowExecutions(ctx context.Context, return nil, wh.error(&gen.BadRequestError{Message: "StartTimeFilter is required"}, scope) } - if listRequest.StartTimeFilter.EarliestTime == nil { + if listRequest.StartTimeFilter.GetLatestTime() == 0 { return nil, wh.error(&gen.BadRequestError{Message: "EarliestTime in StartTimeFilter is required"}, scope) } - if listRequest.StartTimeFilter.LatestTime == nil { + if listRequest.StartTimeFilter.GetEarliestTime() == 0 { return nil, wh.error(&gen.BadRequestError{Message: "LatestTime in StartTimeFilter is required"}, scope) } @@ -1738,7 +1732,7 @@ func (wh *WorkflowHandler) ListClosedWorkflowExecutions(ctx context.Context, Message: "Only one of ExecutionFilter, TypeFilter or StatusFilter is allowed"}, scope) } - if listRequest.MaximumPageSize == nil || listRequest.GetMaximumPageSize() == 0 { + if listRequest.GetMaximumPageSize() == 0 { listRequest.MaximumPageSize = common.Int32Ptr(wh.config.DefaultVisibilityMaxPageSize) } @@ -1798,14 +1792,10 @@ func (wh *WorkflowHandler) QueryWorkflow(ctx context.Context, return nil, wh.error(errRequestNotSet, scope) } - if queryRequest.Domain == nil { + if queryRequest.GetDomain() == "" { return nil, wh.error(errDomainNotSet, scope) } - if queryRequest.Execution == nil { - return nil, wh.error(errExecutionNotSet, scope) - } - if err := wh.validateExecution(queryRequest.Execution, scope); err != nil { return nil, err } @@ -1814,7 +1804,7 @@ func (wh *WorkflowHandler) QueryWorkflow(ctx context.Context, return nil, wh.error(errQueryNotSet, scope) } - if queryRequest.Query.QueryType == nil { + if queryRequest.Query.GetQueryType() == "" { return nil, wh.error(errQueryTypeNotSet, scope) } @@ -1903,7 +1893,7 @@ func (wh *WorkflowHandler) DescribeWorkflowExecution(ctx context.Context, reques return nil, wh.error(createServiceBusyError(), scope) } - if request.Domain == nil { + if request.GetDomain() == "" { return nil, wh.error(errDomainNotSet, scope) } domainID, err := wh.domainCache.GetDomainID(request.GetDomain()) @@ -1943,7 +1933,7 @@ func (wh *WorkflowHandler) DescribeTaskList(ctx context.Context, request *gen.De return nil, wh.error(createServiceBusyError(), scope) } - if request.Domain == nil { + if request.GetDomain() == "" { return nil, wh.error(errDomainNotSet, scope) } domainID, err := wh.domainCache.GetDomainID(request.GetDomain())