windmill-labs / windmill

Open-source developer platform to turn scripts into workflows and UIs. Fastest workflow engine (5x vs Airflow). Open-source alternative to Airplane and Retool.
https://windmill.dev
Other
9.2k stars 408 forks source link

feature: Let error handlers handle multiple errors at once #4043

Open wasnertobias opened 2 weeks ago

wasnertobias commented 2 weeks ago

When changing a branchall without skip failures from not-parallel to parallel the error handling behaviour changes.

When non-parallel only the mapped output of the error handler of the first failed branch is returned.

When parallel: All results of all branches are returned, failed branches return the output of the error handler, successful branches return the result of the last step in the branch.

When you would let error handlers handle multiple errors at once, then the parallel branches case could return only the "mapped output of the error handler" as well.

Why is this important? Because we want to directly use the flow as a REST endpoint and we need to return errors in one well-defined format, even when unexpected. E.g., only single errors should be returned - and only the description of the error. There should never be any step results returned.

rubenfiszel commented 2 weeks ago

@wasnertobias wouldn't you be served better by using "Skip failures" and a branchone ?

I think error handler is a bit of a misnomer, we should call it the "fallback error handler". The better error handlers should be set exactly at the position they are required using skip failures + branchone.

However, I think there is indeed an argument for parallel forloop + branchall to have a toggle to that make them call the error handler themselves too instead of returning straight the failure. Will add to todo-list.

wasnertobias commented 2 weeks ago

parallel => Preferred for performance reason

Skip failure => Not really what we would like to do: Basically, we would have to check after each branchall manually if any error happened and then early return, because we do not want to continue the flow on failure. (So we basically do not want to skip on failure.)

What exactly would this toggle do, it would call the error handler itself, so it would, in fact call the error handler with multiple failures/branch error results?

rubenfiszel commented 2 weeks ago

What exactly would this toggle do, it would call the error handler itself, so it would, in fact call the error handler with multiple failures/branch error results?

It would indeed call the error handler with the entire result, including the failed branch