@@ -2966,6 +2966,9 @@ func (wh *WorkflowHandler) CreateSchedule(ctx context.Context, request *workflow
2966
2966
return nil , err
2967
2967
}
2968
2968
2969
+ // Add namespace division before unaliasing search attributes.
2970
+ searchattribute .AddSearchAttribute (& request .SearchAttributes , searchattribute .TemporalNamespaceDivision , payload .EncodeString (scheduler .NamespaceDivision ))
2971
+
2969
2972
request , err = wh .unaliasCreateScheduleRequestSearchAttributes (request , namespaceName )
2970
2973
if err != nil {
2971
2974
return nil , err
@@ -3001,8 +3004,6 @@ func (wh *WorkflowHandler) CreateSchedule(ctx context.Context, request *workflow
3001
3004
}
3002
3005
// Add initial memo for list schedules
3003
3006
wh .addInitialScheduleMemo (request , input )
3004
- // Add namespace division
3005
- searchattribute .AddSearchAttribute (& request .SearchAttributes , searchattribute .TemporalNamespaceDivision , payload .EncodeString (scheduler .NamespaceDivision ))
3006
3007
// Create StartWorkflowExecutionRequest
3007
3008
startReq := & workflowservice.StartWorkflowExecutionRequest {
3008
3009
Namespace : request .Namespace ,
@@ -3070,7 +3071,12 @@ func (wh *WorkflowHandler) validateStartWorkflowArgsForSchedule(
3070
3071
return errIDReusePolicyNotAllowed
3071
3072
}
3072
3073
3073
- if err := wh .validateSearchAttributes (startWorkflow .GetSearchAttributes (), namespaceName ); err != nil {
3074
+ // Unalias startWorkflow search attributes only for validation. Keep aliases in request.
3075
+ unaliasedStartWorkflowSas , err := searchattribute .UnaliasFields (wh .saMapperProvider , startWorkflow .GetSearchAttributes (), namespaceName .String ())
3076
+ if err != nil {
3077
+ return err
3078
+ }
3079
+ if err := wh .validateSearchAttributes (unaliasedStartWorkflowSas , namespaceName ); err != nil {
3074
3080
return err
3075
3081
}
3076
3082
@@ -3164,22 +3170,6 @@ func (wh *WorkflowHandler) DescribeSchedule(ctx context.Context, request *workfl
3164
3170
return err
3165
3171
}
3166
3172
3167
- // map action search attributes
3168
- if sa := queryResponse .Schedule .Action .GetStartWorkflow ().SearchAttributes ; sa != nil {
3169
- saTypeMap , err := wh .saProvider .GetSearchAttributes (wh .visibilityMrg .GetIndexName (), false )
3170
- if err != nil {
3171
- return serviceerror .NewUnavailable (fmt .Sprintf (errUnableToGetSearchAttributesMessage , err ))
3172
- }
3173
- searchattribute .ApplyTypeMap (sa , saTypeMap )
3174
- aliasedSas , err := searchattribute .AliasFields (wh .saMapperProvider , sa , request .Namespace )
3175
- if err != nil {
3176
- return err
3177
- }
3178
- if aliasedSas != nil {
3179
- queryResponse .Schedule .Action .GetStartWorkflow ().SearchAttributes = aliasedSas
3180
- }
3181
- }
3182
-
3183
3173
// for all running workflows started by the schedule, we should check that they're
3184
3174
// still running, and if not, poke the schedule to refresh
3185
3175
needRefresh := false
@@ -3313,11 +3303,6 @@ func (wh *WorkflowHandler) UpdateSchedule(ctx context.Context, request *workflow
3313
3303
return nil , err
3314
3304
}
3315
3305
3316
- request , err = wh .unaliasUpdateScheduleRequestStartWorkflowSearchAttributes (request , namespaceName )
3317
- if err != nil {
3318
- return nil , err
3319
- }
3320
-
3321
3306
input := & schedspb.FullUpdateRequest {
3322
3307
Schedule : request .Schedule ,
3323
3308
}
@@ -4960,13 +4945,7 @@ func (wh *WorkflowHandler) unaliasCreateScheduleRequestSearchAttributes(request
4960
4945
return nil , err
4961
4946
}
4962
4947
4963
- startWorkflow := request .GetSchedule ().GetAction ().GetStartWorkflow ()
4964
- unaliasedStartWorkflowSas , err := searchattribute .UnaliasFields (wh .saMapperProvider , startWorkflow .GetSearchAttributes (), namespaceName .String ())
4965
- if err != nil {
4966
- return nil , err
4967
- }
4968
-
4969
- if unaliasedSas == nil && unaliasedStartWorkflowSas == nil {
4948
+ if unaliasedSas == nil {
4970
4949
return request , nil
4971
4950
}
4972
4951
@@ -4977,41 +4956,5 @@ func (wh *WorkflowHandler) unaliasCreateScheduleRequestSearchAttributes(request
4977
4956
newRequest .SearchAttributes = unaliasedSas
4978
4957
}
4979
4958
4980
- if unaliasedStartWorkflowSas != nil && startWorkflow != nil {
4981
- newStartWorkflow := * startWorkflow
4982
- newStartWorkflow .SearchAttributes = unaliasedStartWorkflowSas
4983
- newSchedule := * request .GetSchedule ()
4984
- newSchedule .Action = & schedpb.ScheduleAction {
4985
- Action : & schedpb.ScheduleAction_StartWorkflow {
4986
- StartWorkflow : & newStartWorkflow ,
4987
- }}
4988
- newRequest .Schedule = & newSchedule
4989
- }
4990
-
4991
- return & newRequest , nil
4992
- }
4993
-
4994
- func (wh * WorkflowHandler ) unaliasUpdateScheduleRequestStartWorkflowSearchAttributes (request * workflowservice.UpdateScheduleRequest , namespaceName namespace.Name ) (* workflowservice.UpdateScheduleRequest , error ) {
4995
- startWorkflow := request .GetSchedule ().GetAction ().GetStartWorkflow ()
4996
- if startWorkflow == nil {
4997
- return request , nil
4998
- }
4999
-
5000
- unaliasedSas , err := searchattribute .UnaliasFields (wh .saMapperProvider , startWorkflow .GetSearchAttributes (), namespaceName .String ())
5001
- if err != nil {
5002
- return nil , err
5003
- }
5004
- if unaliasedSas == nil {
5005
- return request , nil
5006
- }
5007
- newStartWorkflow := * startWorkflow
5008
- newStartWorkflow .SearchAttributes = unaliasedSas
5009
- newSchedule := * request .GetSchedule ()
5010
- newSchedule .Action = & schedpb.ScheduleAction {
5011
- Action : & schedpb.ScheduleAction_StartWorkflow {
5012
- StartWorkflow : & newStartWorkflow ,
5013
- }}
5014
- newRequest := * request
5015
- newRequest .Schedule = & newSchedule
5016
4959
return & newRequest , nil
5017
4960
}
0 commit comments