java-sdk icon indicating copy to clipboard operation
java-sdk copied to clipboard

Add more details to WorkflowTaskRetryHandler

Open TheForbiddenAi opened this issue 7 months ago • 8 comments

Describe the proposal

Add task name and task input to WorkflowTaskRetryContext to allow for additional error-handling capabilities in the RetryHandler.

TheForbiddenAi avatar Jun 13 '25 13:06 TheForbiddenAi

/assign

TheForbiddenAi avatar Jun 13 '25 13:06 TheForbiddenAi

@TheForbiddenAi thank you for the issue and pr. Could you pleae clarify what "additional error-handling capabilities" mean ?

siri-varma avatar Jun 13 '25 16:06 siri-varma

@siri-varma Yea so let's say you want to control the retry handlers flow based off of a field in the input object for the activity. As of now you can only access the input values of workflow and not the activities or child workflows.

Additionally, if you want to wanted to be able to have one central retry handler but still want to have some small amount of activity specific logic. There is no way to know what activity is currently executing. The workaround for this now would be to create a whole new retry handler and chain it to the original retry handler. But that will lead to duplicate code if you have code in the original retry handler that has to be executed before the activity specific handler.

TheForbiddenAi avatar Jun 13 '25 16:06 TheForbiddenAi

Thank you for the explanation. If my understanding is right, you want to change the retry handler based on input to the activity.

Within a workflow, when activities are triggered, the input to the activity is something we send isn't it ? So, my assumption is we already have access to the input or am I missing something

siri-varma avatar Jun 16 '25 13:06 siri-varma

Yes, that is right. However, we don't have access to the activity/child workflows input because we pass the parent workflow context not the activity context. We do have access to the parent workflow input via the context.

TheForbiddenAi avatar Jun 16 '25 13:06 TheForbiddenAi

If you don't mind, can you add an example of your use case in the PR ? That will make things more clear.

May be here https://github.com/dapr/java-sdk/tree/master/examples/src/main/java/io/dapr/examples/workflows

siri-varma avatar Jun 16 '25 14:06 siri-varma

@siri-varma I added an example. Another thing to note is that having access to the input at retry handle time would allow the input to be extracted and sent elsewhere (i.e. an incident report). I still need to update the readme and will do that in a little bit

TheForbiddenAi avatar Jun 16 '25 16:06 TheForbiddenAi

readme has been updated

TheForbiddenAi avatar Jun 16 '25 18:06 TheForbiddenAi