@@ -538,9 +538,10 @@ internal static P.PurgeInstancesResponse CreatePurgeInstancesResponse(PurgeResul
538538 /// Converts a <see cref="P.EntityBatchResult" /> to a <see cref="OperationBatchResult" />.
539539 /// </summary>
540540 /// <param name="entityBatchResult">The operation result to convert.</param>
541+ /// <param name="defaultVersion">The default version to use for orchestrations started by the entity when no explicit version is specified.</param>
541542 /// <returns>The converted operation result.</returns>
542543 [ return : NotNullIfNotNull ( "entityBatchResult" ) ]
543- internal static EntityBatchResult ? ToEntityBatchResult ( this P . EntityBatchResult ? entityBatchResult )
544+ internal static EntityBatchResult ? ToEntityBatchResult ( this P . EntityBatchResult ? entityBatchResult , string ? defaultVersion = null )
544545 {
545546 if ( entityBatchResult == null )
546547 {
@@ -549,7 +550,7 @@ internal static P.PurgeInstancesResponse CreatePurgeInstancesResponse(PurgeResul
549550
550551 return new EntityBatchResult ( )
551552 {
552- Actions = entityBatchResult . Actions . Select ( operationAction => operationAction ! . ToOperationAction ( ) ) . ToList ( ) ,
553+ Actions = entityBatchResult . Actions . Select ( operationAction => operationAction ! . ToOperationAction ( defaultVersion ) ) . ToList ( ) ,
553554 EntityState = entityBatchResult . EntityState ,
554555 Results = entityBatchResult . Results . Select ( operationResult => operationResult ! . ToOperationResult ( ) ) . ToList ( ) ,
555556 FailureDetails = GetFailureDetails ( entityBatchResult . FailureDetails ) ,
@@ -560,9 +561,10 @@ internal static P.PurgeInstancesResponse CreatePurgeInstancesResponse(PurgeResul
560561 /// Converts a <see cref="P.OperationAction" /> to a <see cref="OperationAction" />.
561562 /// </summary>
562563 /// <param name="operationAction">The operation action to convert.</param>
564+ /// <param name="defaultVersion">The default version to use for orchestrations started by the entity when no explicit version is specified.</param>
563565 /// <returns>The converted operation action.</returns>
564566 [ return : NotNullIfNotNull ( "operationAction" ) ]
565- internal static OperationAction ? ToOperationAction ( this P . OperationAction ? operationAction )
567+ internal static OperationAction ? ToOperationAction ( this P . OperationAction ? operationAction , string ? defaultVersion = null )
566568 {
567569 if ( operationAction == null )
568570 {
@@ -588,13 +590,21 @@ internal static P.PurgeInstancesResponse CreatePurgeInstancesResponse(PurgeResul
588590 } ;
589591
590592 case P . OperationAction . OperationActionTypeOneofCase . StartNewOrchestration :
593+ // Apply the default version if no explicit version is provided.
594+ // This ensures orchestrations scheduled from entities use the host's default version,
595+ // consistent with orchestrations started via the client or from other orchestrations.
596+ string ? version = operationAction . StartNewOrchestration . Version ;
597+ if ( string . IsNullOrWhiteSpace ( version ) )
598+ {
599+ version = defaultVersion ;
600+ }
591601
592602 return new StartNewOrchestrationOperationAction ( )
593603 {
594604 Name = operationAction . StartNewOrchestration . Name ,
595605 Input = operationAction . StartNewOrchestration . Input ,
596606 InstanceId = operationAction . StartNewOrchestration . InstanceId ,
597- Version = operationAction . StartNewOrchestration . Version ,
607+ Version = version ,
598608 RequestTime = operationAction . StartNewOrchestration . RequestTime ? . ToDateTimeOffset ( ) ,
599609 ScheduledStartTime = operationAction . StartNewOrchestration . ScheduledTime ? . ToDateTime ( ) ,
600610 ParentTraceContext = operationAction . StartNewOrchestration . ParentTraceContext != null ?
0 commit comments