Replies: 10 comments 6 replies
-
@LeifLazar thank you very much for your input! You make a good point, and I can see how this could improve clarity. However, this would be a significant breaking change, so it will require a detailed discussion to evaluate its impact across existing implementations. Looking forward to hearing more perspectives on this. @ricardozanini @JBBianchi @fjtirado @matthias-pichler What do you guys think? |
Beta Was this translation helpful? Give feedback.
-
Arent we allowing already nested try catch (which I believe is the solution for applying a global policy to a set of task and a particular behaviour to individual ones)? |
Beta Was this translation helpful? Give feedback.
-
@cdavernas I was thinking that this would be an optional addition and it wouldn't break compatibility. @fjtirado Indeed, that's what I was trying to avoid. That nesting grows super fast. This improvement would not make a huge functional difference but it would help to slim down workflow definitions. |
Beta Was this translation helpful? Give feedback.
-
@LeifLazar Ok, got it. Can is you illustrate the two proposals with a "code snippet" of how it looks now and how it will look with the modification? That I guess will help to focus the dicussion |
Beta Was this translation helpful? Give feedback.
-
My proposal is not aiming to get rid of the try-catch but to provide an option to specify resiliency policies on any task, without being forced to use try-catch and its implicit nesting. A common scenario (at least in my mind) is when we have a group of n tasks in a try - catch block which handles 503 errors, but on one of the tasks we want to further handle 4xx errors and we know that another task is susceptible to 504s. We would have to wrap those tasks in two other try-catch blocks. To oversimplify a bit:
vs.
I'm thinking that the nesting gets worse with larger and more intricate workflow definitions. I will spend some time to create a real-life scenario comparison of the two approaches. |
Beta Was this translation helpful? Give feedback.
-
I like the shortcut, but this will break the public API we have now for 1.0.0 since every task must have a handle definition for this proposal to be in. It can be done if we bend the rules. But we need more examples, discussions, and a migration path. Ideally, what was written in 1.0.0 should work on 1.1.0 (if we add this, it should at least be a minor patch - we can't do majors so soon IMO). I haven't looked at the schema yet in detail, but that's my main concern. |
Beta Was this translation helpful? Give feedback.
-
I like the idea of simplifying the error handling. What about getting rid of document:
#...
do:
- myFirstTask:
do:
- aSubTask:
#...
- anotherSubTask:
call: http
with: #...
catch: #<-- catch on a single task
errors:
with:
status: 503
#...
as: error
retry:
#...
- mySecondTask:
call: http
with: #...
- myThirdTask:
do:
- yetAnotherSubTask:
#...
- someSubTask:
call: http
with: #...
catch: #<-- catch on a group of tasks
errors:
with:
status: 503
#...
as: error
retry:
#...
catch: #<-- global catch
errors:
with:
status: 503
#...
as: error
retry:
#... This would break backward compatibility though. We could mark |
Beta Was this translation helpful? Give feedback.
-
I think simplifying error handling is definitely worthwhile. 👍 From a versioning perspective adding an optional So I am in favor of @JBBianchi 's proposal to add |
Beta Was this translation helpful? Give feedback.
-
Indeed, we can add an optional Later, we remove |
Beta Was this translation helpful? Give feedback.
-
@LeifLazar I think we all reached a consensus. Do you want to open the related issue and maybe work on the PR? |
Beta Was this translation helpful? Give feedback.
-
Hello!
Looking at the spec for Retry and Catch and also at the examples, it seems that Retry nodes are only permitted on Catch blocks.
If that's the case and I didn't miss anything, I'd like to discuss the feasibility of allowing Retry nodes on any Task.
Starting from this example
try-catch-retry-inline
If we wanted to do two API calls and either handle different errors or simply apply different policies, we'd have to do something like this:
Two Tasks
The workflow definition gets polluted and readability takes a hit even on simple examples. Nesting gets out of hand fast in a scenario where we'd want to try 3 tasks, handle 5XX errors on all but also handle 4XX errors on only one of them. We'd need nested try-catch blocks.
A naive proposal to try and solve this would look something like this:
Naive
This still doesn't look ideal, but if we'd allow setting the errors filter as an optional parameter of the Retry node, it would look a lot better. I say optional parameter because it would allow "retry on any error" types of behavior if it's not defined. Not sure if that's valuable or not.
Better
Another route would be to leverage the
when
andexceptWhen
parameters of the Retry block but I didn't find any info on whether those runtime expressions have access to the error object or not. If they do, that would eliminate the need for theerrors
parameter to exist at Retry level.Of course, any solution would slightly increase the run-time implementation complexity but it shouldn't be too big of a hit since the same logic would anyway have to be implemented for the try-catch block.
Is this even a valid discussion to have? Are there better ways to achieve this?
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions