Is there a means to get the failure details for a FAILED workflow with information like stack trace, exceptions, timeout details etc?
I can see a means to get that detail for RUNNING
workflows which have failing retryable activities using describeWorkflowExecutionResponse.getPendingActivitiesList().get(0).getLastFailure()
but the same method wouldn’t work for FAILED
workflows as PendingActivitiesList
would be empty.
I see that this information is available in the Temporal web UI (under Summary tab for a particular execution) but I was looking to see if it was possible to get the same information via the Java SDK.
Hi @ali_akbar
for failed workflows you can attach to the failed workflow execution by using newWorkflowStub method for a known execution and then get the failure via getResult:
MyWorkflow myFailedWorkflow =
client.newWorkflowStub(
MyWorkflow.class,
"<workflow_id>",
Optional.of("<workflow_run_id>"));
WorkflowStub untyped = WorkflowStub.fromTyped(myFailedWorkflow);
try {
untyped.getResult(String.class);
} catch (WorkflowFailedException e) {
// ...
if (e.getCause() instanceof ActivityFailure) {
ActivityFailure activityFailure = (ActivityFailure) e.getCause();
// ...
}
if (e.getCause() instanceof ChildWorkflowFailure) {
ChildWorkflowFailure childWorkflowFailure = (ChildWorkflowFailure) e.getCause();
}
// ...
}
1 Like
Thanks for the quick response. This approach seems to solve my use case. 
For my solution, I already had the WorkflowExecution
object so I just went ahead and created an untyped stub like so and the rest was pretty much the same:
WorkflowStub untypedStub = client.newUntypedWorkflowStub(workflowExecution, Optional.empty());