Skip to content

Commit

Permalink
Misc. improvements for error checking (#2602)
Browse files Browse the repository at this point in the history
  • Loading branch information
yycptt committed Mar 14, 2022
1 parent cafdda9 commit 3a3057e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
8 changes: 4 additions & 4 deletions service/frontend/workflowHandler.go
Expand Up @@ -959,6 +959,10 @@ func (wh *WorkflowHandler) RespondWorkflowTaskCompleted(
return nil, errRequestNotSet
}

if len(request.GetIdentity()) > wh.config.MaxIDLengthLimit() {
return nil, errIdentityTooLong
}

taskToken, err := wh.tokenSerializer.Deserialize(request.TaskToken)
if err != nil {
return nil, err
Expand All @@ -973,10 +977,6 @@ func (wh *WorkflowHandler) RespondWorkflowTaskCompleted(
return nil, err
}

if len(request.GetIdentity()) > wh.config.MaxIDLengthLimit() {
return nil, errIdentityTooLong
}

completedResp := &workflowservice.RespondWorkflowTaskCompletedResponse{}
if request.GetReturnNewWorkflowTask() && histResp != nil && histResp.StartedResponse != nil {
taskToken := &tokenspb.Task{
Expand Down
10 changes: 9 additions & 1 deletion service/history/workflow/mutable_state_impl.go
Expand Up @@ -3236,7 +3236,15 @@ func (e *MutableStateImpl) ReplicateChildWorkflowExecutionStartedEvent(
attributes := event.GetChildWorkflowExecutionStartedEventAttributes()
initiatedID := attributes.GetInitiatedEventId()

ci, _ := e.GetChildExecutionInfo(initiatedID)
ci, ok := e.GetChildExecutionInfo(initiatedID)
if !ok {
e.logError(
fmt.Sprintf("unable to find child workflow event ID: %v in mutable state", initiatedID),
tag.ErrorTypeInvalidMutableStateAction,
)
return ErrMissingChildWorkflowInfo
}

ci.StartedId = event.GetEventId()
ci.StartedRunId = attributes.GetWorkflowExecution().GetRunId()
e.updateChildExecutionInfos[ci.InitiatedId] = ci
Expand Down

0 comments on commit 3a3057e

Please sign in to comment.