How can I keep one Step Functions branch running when another branch fails?

0
1
Asked By MellowCedar42 On

I have a workflow where GetDataLambda must run first because both processing pipelines depend on its output. After that, I want to run two independent branches in parallel: ProcessDataLambdaA1 -> ProcessDataLambdaA2 on one side, and ProcessDataLambdaB1 -> ProcessDataLambdaB2 on the other. The issue is that a failure in one branch causes the entire Parallel state to fail, even though the other branch could continue safely. What is the recommended way to catch or isolate errors so that, for example, the B branch keeps running when the A branch fails?

2 Answers

Answered By BrightOrchid7 On

Keep the Parallel state, but handle errors inside each branch rather than letting them bubble up to the Parallel state. Add a Catch transition to the processing states in branch A and send failures to an AFailed or ACompleteWithError state. Do the equivalent for branch B. Once each branch reaches its own terminal state, the Parallel state can finish without one branch cancelling the other. It’s also useful to include the caught error details in the branch output so you can see which path succeeded or failed.

MellowCedar42 -

Would the AFailed state need to be treated as a successful terminal state for the Parallel state to continue?

Answered By QuietMaple19 On

A common pattern is to route errors to a Pass state at the end of each branch. For example, the normal A flow could be ProcessDataLambdaA1 -> ProcessDataLambdaA2 -> PassA. Add Catch handlers to the Lambda states so that an error skips to PassA instead of escaping the branch. From the Parallel state’s perspective, the branch then completes normally, while the output can still record that the processing failed. If later steps need to distinguish success from failure, set a status such as ProcessAStatus or ProcessBStatus on the normal and error paths, then evaluate those values with a Choice state afterward.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.