Skip to content

Commit a05c855

Browse files
Fix UNKNOWN gRPC error on describe (#2672)
1 parent 785f5cd commit a05c855

File tree

2 files changed

+27
-11
lines changed

2 files changed

+27
-11
lines changed

temporal-test-server/src/main/java/io/temporal/internal/testservice/StateMachines.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -393,14 +393,22 @@ public String toString() {
393393
static final class ChildWorkflowData {
394394

395395
final TestWorkflowService service;
396+
final String workflowId;
397+
final String workflowType;
396398
final UserMetadata metadata;
397399
StartChildWorkflowExecutionInitiatedEventAttributes initiatedEvent;
398400
long initiatedEventId;
399401
long startedEventId;
400402
WorkflowExecution execution;
401403

402-
public ChildWorkflowData(TestWorkflowService service, UserMetadata metadata) {
404+
public ChildWorkflowData(
405+
TestWorkflowService service,
406+
String workflowId,
407+
String workflowType,
408+
UserMetadata metadata) {
403409
this.service = service;
410+
this.workflowId = workflowId;
411+
this.workflowType = workflowType;
404412
this.metadata = metadata;
405413
}
406414

@@ -568,8 +576,8 @@ public static StateMachine<ActivityTaskData> newActivityStateMachine(
568576
}
569577

570578
public static StateMachine<ChildWorkflowData> newChildWorkflowStateMachine(
571-
TestWorkflowService service, UserMetadata metadata) {
572-
return new StateMachine<>(new ChildWorkflowData(service, metadata))
579+
TestWorkflowService service, String workflowId, String workflowType, UserMetadata metadata) {
580+
return new StateMachine<>(new ChildWorkflowData(service, workflowId, workflowType, metadata))
573581
.add(NONE, INITIATE, INITIATED, StateMachines::initiateChildWorkflow)
574582
.add(INITIATED, START, STARTED, StateMachines::childWorkflowStarted)
575583
.add(INITIATED, FAIL, FAILED, StateMachines::startChildWorkflowFailed)

temporal-test-server/src/main/java/io/temporal/internal/testservice/TestWorkflowMutableStateImpl.java

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,7 +1150,8 @@ private void processStartChildWorkflow(
11501150
long workflowTaskCompletedId) {
11511151
a = validateStartChildExecutionAttributes(a);
11521152
StateMachine<ChildWorkflowData> child =
1153-
StateMachines.newChildWorkflowStateMachine(service, metadata);
1153+
StateMachines.newChildWorkflowStateMachine(
1154+
service, a.getWorkflowId(), a.getWorkflowType().getName(), metadata);
11541155
childWorkflows.put(ctx.getNextEventId(), child);
11551156
child.action(StateMachines.Action.INITIATE, ctx, a, workflowTaskCompletedId);
11561157
ctx.lockTimer("processStartChildWorkflow");
@@ -3253,13 +3254,20 @@ private DescribeWorkflowExecutionResponse describeWorkflowExecutionInsideLock()
32533254
private static PendingChildExecutionInfo constructPendingChildExecutionInfo(
32543255
StateMachine<ChildWorkflowData> sm) {
32553256
ChildWorkflowData data = sm.getData();
3256-
return PendingChildExecutionInfo.newBuilder()
3257-
.setWorkflowId(data.execution.getWorkflowId())
3258-
.setRunId(data.execution.getRunId())
3259-
.setWorkflowTypeName(data.initiatedEvent.getWorkflowType().getName())
3260-
.setInitiatedId(data.initiatedEventId)
3261-
.setParentClosePolicy(data.initiatedEvent.getParentClosePolicy())
3262-
.build();
3257+
PendingChildExecutionInfo.Builder builder =
3258+
PendingChildExecutionInfo.newBuilder()
3259+
.setWorkflowId(data.workflowId)
3260+
.setWorkflowTypeName(data.workflowType);
3261+
// These fields may not be set if the child workflow hasn't been started yet
3262+
if (data.execution != null) {
3263+
builder.setRunId(data.execution.getRunId());
3264+
}
3265+
if (data.initiatedEvent != null) {
3266+
builder
3267+
.setInitiatedId(data.initiatedEventId)
3268+
.setParentClosePolicy(data.initiatedEvent.getParentClosePolicy());
3269+
}
3270+
return builder.build();
32633271
}
32643272

32653273
private static PendingActivityInfo constructPendingActivityInfo(

0 commit comments

Comments
 (0)