@@ -50,19 +50,24 @@ func createSubWorkflowInstance[TResult any](ctx Context, options SubWorkflowOpti
5050 }
5151
5252 // Check return type
53- if err := a.ReturnTypeMatch [TResult ](wf ); err != nil {
54- f .Set (* new (TResult ), err )
55- return f
56- }
53+ var workflowName string
54+ if name , ok := wf .(string ); ok {
55+ workflowName = name
56+ } else {
57+ workflowName = fn .Name (wf )
58+
59+ if err := a.ReturnTypeMatch [TResult ](wf ); err != nil {
60+ f .Set (* new (TResult ), err )
61+ return f
62+ }
5763
58- // Check arguments
59- if err := a .ParamsMatch (wf , args ... ); err != nil {
60- f .Set (* new (TResult ), err )
61- return f
64+ // Check arguments
65+ if err := a .ParamsMatch (wf , args ... ); err != nil {
66+ f .Set (* new (TResult ), err )
67+ return f
68+ }
6269 }
6370
64- name := fn .Name (wf )
65-
6671 cv := contextvalue .Converter (ctx )
6772 inputs , err := a .ArgsToInputs (cv , args ... )
6873 if err != nil {
@@ -74,9 +79,9 @@ func createSubWorkflowInstance[TResult any](ctx Context, options SubWorkflowOpti
7479 scheduleEventID := wfState .GetNextScheduleEventID ()
7580
7681 ctx , span := workflowtracer .Tracer (ctx ).Start (ctx ,
77- fmt .Sprintf ("CreateSubworkflowInstance: %s" , name ),
82+ fmt .Sprintf ("CreateSubworkflowInstance: %s" , workflowName ),
7883 trace .WithAttributes (
79- attribute .String (log .WorkflowNameKey , name ),
84+ attribute .String (log .WorkflowNameKey , workflowName ),
8085 attribute .Int64 (log .ScheduleEventIDKey , scheduleEventID ),
8186 attribute .Int (log .AttemptKey , attempt ),
8287 ))
@@ -90,7 +95,7 @@ func createSubWorkflowInstance[TResult any](ctx Context, options SubWorkflowOpti
9095 return f
9196 }
9297
93- cmd := command .NewScheduleSubWorkflowCommand (scheduleEventID , wfState .Instance (), options .InstanceID , name , inputs , metadata )
98+ cmd := command .NewScheduleSubWorkflowCommand (scheduleEventID , wfState .Instance (), options .InstanceID , workflowName , inputs , metadata )
9499
95100 wfState .AddCommand (cmd )
96101 wfState .TrackFuture (scheduleEventID , workflowstate .AsDecodingSettable (cv , f ))
0 commit comments