Skip to content

Commit

Permalink
IWF-372: Fix GetSearchAttributes returning nil when no IwfExecutionSt…
Browse files Browse the repository at this point in the history
…ateIds are set (#505)
  • Loading branch information
lwolczynski authored Dec 6, 2024
1 parent e23bbd0 commit a33475d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
9 changes: 5 additions & 4 deletions integ/wait_until_search_attributes_optimization_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,18 +140,19 @@ func doTestWaitUntilHistoryCompleted(
assertions.Equal([]string{"S3", "S6"}, historyEventSAs(upsertSAEvents[7]))
assertions.Equal([]string{"S3"}, historyEventSAs(upsertSAEvents[8]))
assertions.Equal([]string{"null"}, historyEventSAs(upsertSAEvents[9]))
case iwfidl.DISABLED:
assertions.Equal(1, len(upsertSAEvents))
case iwfidl.ENABLED_FOR_STATES_WITH_WAIT_UNTIL:
default:
assertions.Equal(9, len(upsertSAEvents))
assertions.Equal([]string{"S1"}, historyEventSAs(upsertSAEvents[1]))
assertions.Equal([]string{"S2"}, historyEventSAs(upsertSAEvents[2]))
assertions.Equal([]string{"S2", "S3"}, historyEventSAs(upsertSAEvents[3]))
assertions.Equal([]string{"null"}, historyEventSAs(upsertSAEvents[2]))
assertions.Equal([]string{"S3"}, historyEventSAs(upsertSAEvents[3]))
assertions.Equal([]string{"S3", "S4"}, historyEventSAs(upsertSAEvents[4]))
assertions.Equal([]string{"S3"}, historyEventSAs(upsertSAEvents[5]))
assertions.Equal([]string{"S3", "S6"}, historyEventSAs(upsertSAEvents[6]))
assertions.Equal([]string{"S3"}, historyEventSAs(upsertSAEvents[7]))
assertions.Equal([]string{"null"}, historyEventSAs(upsertSAEvents[8]))
case iwfidl.DISABLED:
assertions.Equal(1, len(upsertSAEvents))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ func (h *handler) ApiV1WorkflowStateDecide(c *gin.Context) {
NextStates: []iwfidl.StateMovement{
{
StateId: State2,
StateOptions: &iwfidl.WorkflowStateOptions{
SkipWaitUntil: iwfidl.PtrBool(true),
},
},
},
},
Expand Down Expand Up @@ -192,6 +195,9 @@ func (h *handler) ApiV1WorkflowStateDecide(c *gin.Context) {
NextStates: []iwfidl.StateMovement{
{
StateId: State2,
StateOptions: &iwfidl.WorkflowStateOptions{
SkipWaitUntil: iwfidl.PtrBool(true),
},
},
{
StateId: State3,
Expand Down
8 changes: 8 additions & 0 deletions service/common/mapper/searchAttribute.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ func MapCadenceToIwfSearchAttributes(searchAttributes *shared.SearchAttributes,
if err != nil {
return nil, err
}
// when SAs are nil, skip calling mapToIwfSearchAttribute
if object == nil {
continue
}
rv, err := mapToIwfSearchAttribute(key, sa.GetValueType(), object, true)
if err != nil {
return nil, err
Expand Down Expand Up @@ -94,6 +98,10 @@ func MapTemporalToIwfSearchAttributes(searchAttributes *common.SearchAttributes,
}
// TODO we should also call UseNumber here for JSON decoder for Temporal
// see https://github.com/temporalio/sdk-go/issues/942
// when SAs are nil, skip calling mapToIwfSearchAttribute
if object == nil {
continue
}
rv, err := mapToIwfSearchAttribute(key, sa.GetValueType(), object, false)
if err != nil {
return nil, err
Expand Down
1 change: 1 addition & 0 deletions service/interpreter/stateExecutionCounter.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ func (e *StateExecutionCounter) refreshIwfExecutingStateIdSearchAttribute() erro
})
if err != nil {
e.provider.GetLogger(e.ctx).Error("error for GetSearchAttributes", err)
return err
}

var currentSAsValues []string
Expand Down

0 comments on commit a33475d

Please sign in to comment.