Skip to content

Commit

Permalink
Fallback to zero value for initiatedID in exteralWorkflowExecutionFie…
Browse files Browse the repository at this point in the history
…lds struct (#4720)
  • Loading branch information
Shaddoll authored Feb 1, 2022
1 parent b0dff80 commit dea6429
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
5 changes: 1 addition & 4 deletions common/types/mapper/proto/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -4297,12 +4297,9 @@ func FromExternalExecutionInfoFields(we *types.WorkflowExecution, initiatedID *i
if we == nil && initiatedID == nil {
return nil
}
if we == nil || initiatedID == nil {
panic("either all or none external execution info fields must be set")
}
return &apiv1.ExternalExecutionInfo{
WorkflowExecution: FromWorkflowExecution(we),
InitiatedId: *initiatedID,
InitiatedId: common.Int64Default(initiatedID), // TODO: we need to figure out whetherrr this field is needed or not
}
}

Expand Down
13 changes: 10 additions & 3 deletions common/types/mapper/proto/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -721,9 +721,16 @@ func TestExternalExecutionInfo(t *testing.T) {
assert.Nil(t, FromExternalExecutionInfoFields(nil, nil))
assert.Nil(t, ToExternalWorkflowExecution(nil))
assert.Nil(t, ToExternalInitiatedID(nil))
assert.Panics(t, func() { FromExternalExecutionInfoFields(nil, common.Int64Ptr(testdata.EventID1)) })
assert.Panics(t, func() { FromExternalExecutionInfoFields(&testdata.WorkflowExecution, nil) })
info := FromExternalExecutionInfoFields(&testdata.WorkflowExecution, common.Int64Ptr(testdata.EventID1))

info := FromExternalExecutionInfoFields(nil, common.Int64Ptr(testdata.EventID1))
assert.Nil(t, ToExternalWorkflowExecution(nil))
assert.Equal(t, testdata.EventID1, *ToExternalInitiatedID(info))

info = FromExternalExecutionInfoFields(&testdata.WorkflowExecution, nil)
assert.Equal(t, testdata.WorkflowExecution, *ToExternalWorkflowExecution(info))
assert.Equal(t, int64(0), *ToExternalInitiatedID(info))

info = FromExternalExecutionInfoFields(&testdata.WorkflowExecution, common.Int64Ptr(testdata.EventID1))
assert.Equal(t, testdata.WorkflowExecution, *ToExternalWorkflowExecution(info))
assert.Equal(t, testdata.EventID1, *ToExternalInitiatedID(info))
}
Expand Down

0 comments on commit dea6429

Please sign in to comment.