diff --git a/internal/internal_workflow_client.go b/internal/internal_workflow_client.go index 589c5e896..c433d9671 100644 --- a/internal/internal_workflow_client.go +++ b/internal/internal_workflow_client.go @@ -2400,7 +2400,11 @@ func (w *workflowClientInterceptor) createUpdateWorkflowRequest( ctx context.Context, in *ClientUpdateWorkflowInput, ) (*workflowservice.UpdateWorkflowExecutionRequest, error) { - argPayloads, err := w.client.dataConverter.ToPayloads(in.Args...) + dataConverter := WithContext(ctx, w.client.dataConverter) + if dataConverter == nil { + dataConverter = converter.GetDefaultDataConverter() + } + argPayloads, err := dataConverter.ToPayloads(in.Args...) if err != nil { return nil, err } diff --git a/internal/internal_workflow_client_test.go b/internal/internal_workflow_client_test.go index fc605826e..607420b2c 100644 --- a/internal/internal_workflow_client_test.go +++ b/internal/internal_workflow_client_test.go @@ -1471,6 +1471,36 @@ func (s *workflowClientTestSuite) TestSignalWithStartWorkflowWithContextAwareDat s.Equal(startResponse.GetRunId(), resp.GetRunID()) } +func (s *workflowClientTestSuite) TestUpdateWorkflowWithContextAwareDataConverter() { + dc := NewContextAwareDataConverter(converter.GetDefaultDataConverter()) + s.client = NewServiceClient(s.service, nil, ClientOptions{DataConverter: dc}) + client, ok := s.client.(*WorkflowClient) + s.True(ok) + + input := "test" + + updateResponse := &workflowservice.UpdateWorkflowExecutionResponse{ + Stage: enumspb.UPDATE_WORKFLOW_EXECUTION_LIFECYCLE_STAGE_COMPLETED, + Outcome: &updatepb.Outcome{ + Value: &updatepb.Outcome_Success{}, + }, + } + s.service.EXPECT().UpdateWorkflowExecution(gomock.Any(), gomock.Any(), gomock.Any()).Return(updateResponse, nil).Do(func(_ interface{}, req *workflowservice.UpdateWorkflowExecutionRequest, _ ...interface{}) { + dc := client.dataConverter + inputs := dc.ToStrings(req.GetRequest().GetInput().Args) + s.Equal("\"te?t\"", inputs[0]) + }) + ctx := context.Background() + ctx = context.WithValue(ctx, ContextAwareDataConverterContextKey, "s") + + _, err := s.client.UpdateWorkflow(ctx, UpdateWorkflowOptions{ + UpdateName: "my-update", + WaitForStage: WorkflowUpdateStageCompleted, + Args: []interface{}{input}, + }) + s.Nil(err) +} + func (s *workflowClientTestSuite) TestSignalWithStartWorkflowValidation() { // ambiguous WorkflowID _, err := s.client.SignalWithStartWorkflow(