diff --git a/temporalcli/commands.workflow_view.go b/temporalcli/commands.workflow_view.go index 94e721dec..9bfb5337f 100644 --- a/temporalcli/commands.workflow_view.go +++ b/temporalcli/commands.workflow_view.go @@ -117,6 +117,10 @@ func (c *TemporalWorkflowDescribeCommand) run(cctx *CommandContext, args []strin StateTransitionCount int64 HistoryLength int64 HistorySize int64 + ParentWorkflowId string `cli:",cardOmitEmpty"` + ParentRunId string `cli:",cardOmitEmpty"` + RootWorkflowId string `cli:",cardOmitEmpty"` + RootRunId string `cli:",cardOmitEmpty"` }{ WorkflowId: info.Execution.WorkflowId, RunId: info.Execution.RunId, @@ -132,6 +136,10 @@ func (c *TemporalWorkflowDescribeCommand) run(cctx *CommandContext, args []strin StateTransitionCount: info.StateTransitionCount, HistoryLength: info.HistoryLength, HistorySize: info.HistorySizeBytes, + ParentWorkflowId: info.GetParentExecution().GetWorkflowId(), + ParentRunId: info.GetParentExecution().GetRunId(), + RootWorkflowId: info.GetRootExecution().GetWorkflowId(), + RootRunId: info.GetRootExecution().GetRunId(), }, printer.StructuredOptions{}) extendedInfo := resp.WorkflowExtendedInfo diff --git a/temporalcli/commands.workflow_view_test.go b/temporalcli/commands.workflow_view_test.go index 31bfc96af..a758b7815 100644 --- a/temporalcli/commands.workflow_view_test.go +++ b/temporalcli/commands.workflow_view_test.go @@ -993,3 +993,64 @@ func (s *SharedServerSuite) TestWorkflow_Describe_WorkflowMetadata() { s.NotNil(jsonOut.ExecutionConfig.UserMetadata.Summary) s.NotNil(jsonOut.ExecutionConfig.UserMetadata.Details) } + +func (s *SharedServerSuite) TestWorkflow_Describe_RootWorkflow() { + s.Worker().OnDevWorkflow(func(ctx workflow.Context, input any) (any, error) { + if input.(string) == "child" { + return "done", nil + } + ctx = workflow.WithActivityOptions(ctx, workflow.ActivityOptions{ + StartToCloseTimeout: 10 * time.Second, + }) + childHandle := workflow.ExecuteChildWorkflow(ctx, DevWorkflow, "child") + var childWE workflow.Execution + err := childHandle.GetChildWorkflowExecution().Get(ctx, &childWE) + if err != nil { + return nil, err + } + err = childHandle.Get(ctx, nil) + if err != nil { + return nil, err + } + return childWE.ID, err + }) + + run, err := s.Client.ExecuteWorkflow( + s.Context, + client.StartWorkflowOptions{TaskQueue: s.Worker().Options.TaskQueue}, + DevWorkflow, + "ignored", + ) + s.NoError(err) + var wfRes string + err = run.Get(s.Context, &wfRes) + s.NoError(err) + + // Text + res := s.Execute( + "workflow", "describe", + "--address", s.Address(), + "-w", wfRes, + ) + s.NoError(res.Err) + out := res.Stdout.String() + s.ContainsOnSameLine(out, "ParentWorkflowId", run.GetID()) + s.ContainsOnSameLine(out, "ParentRunId", run.GetRunID()) + s.ContainsOnSameLine(out, "RootWorkflowId", run.GetID()) + s.ContainsOnSameLine(out, "RootRunId", run.GetRunID()) + + // JSON + res = s.Execute( + "workflow", "describe", + "-o", "json", + "--address", s.Address(), + "-w", wfRes, + ) + s.NoError(res.Err) + var jsonOut workflowservice.DescribeWorkflowExecutionResponse + s.NoError(temporalcli.UnmarshalProtoJSONWithOptions(res.Stdout.Bytes(), &jsonOut, true)) + s.Equal(run.GetID(), jsonOut.WorkflowExecutionInfo.ParentExecution.GetWorkflowId()) + s.Equal(run.GetRunID(), jsonOut.WorkflowExecutionInfo.ParentExecution.GetRunId()) + s.Equal(run.GetID(), jsonOut.WorkflowExecutionInfo.RootExecution.GetWorkflowId()) + s.Equal(run.GetRunID(), jsonOut.WorkflowExecutionInfo.RootExecution.GetRunId()) +}