Retrieving ActivityFailureInfo during running or completed Workflow

I have a workflow with a few activities inside it. I know how to get the PendingAcitivityInfo list, but I want to get the status of the individual activities.

When the workflow is running, I think getting the PendingActivityInfo list is good enough. But when a workflow fails, I would like to be able to see which Activity failed.

We can get this information perfectly by the tctl workflow showid command, but what is the equivalent of this in code (I’m using Java). I have gone through some documentation and it seems the Activity info is not part of DescribeWorkflowExecutionRequest. Thanks in advance.

I think you would need to get the event history kinda what you mentioned with tctl and then go through it to find any ActivityTaskFailed/TimedOut events, find the associated ActivityTaskScheduled event to get info on this activity and report.

With Java SDK you can get event history with something like:

WorkflowExecutionHistory history = client.fetchHistory("wfid", "runid");
for(HistoryEvent event : history.getEvents()) {
   //...
}

where client is your WorkflowClient