AWS Certified Developer – Associate
Step Functions Retry and Catch error handling for DVA-C03
The AWS Step Functions Developer Guide says that when a state reports an error, the whole execution fails by default. Task, Parallel and Map states can add a Retry array of retriers and a Catch array of catchers. Step Functions applies a matching retrier first, and a catcher only when retries do not resolve the error.
How does Retry work?
Retry is an array of retriers. When the state reports an error, Step Functions scans the retriers in the order listed and uses the first whose ErrorEquals array contains the error name. Put specific error names before wildcards, or the wildcard retrier handles them.
IntervalSeconds is the wait before the first retry and defaults to 1. MaxAttempts defaults to 3, and a value of 0 means the error is never retried. BackoffRate multiplies the interval after each attempt and defaults to 2.0. With an interval of 3, three attempts and a rate of 2, the waits are 3, 6 and 12 seconds.
MaxDelaySeconds caps how far the interval can grow. JitterStrategy accepts FULL or NONE, with NONE as the default. FULL randomizes each wait between 0 and the computed interval, which spreads out retries that would otherwise happen at the same moment.
Retries are treated as state transitions for billing.
How does Catch work?
Catch is an array of catchers. Each has ErrorEquals, a required Next that names the fallback state, and an optional ResultPath. Step Functions scans catchers in order when there is no Retry field or when retries fail to resolve the error.
The fallback state receives the error output, which usually contains a Cause field. In a JSONPath workflow, a catcher without ResultPath uses the default $, so the error output overwrites the whole state input. Setting a path such as $.error-info adds the error output to the original input, and the fallback state receives both.
Catchers handle errors inside Task, Parallel and Map states. They are not available for a top-level execution failure.
Which error names matter?
Error names are case-sensitive strings. Built-in names start with States., and custom error names cannot use that prefix.
States.ALL is a wildcard. It must appear alone in its ErrorEquals array and in the last retrier or catcher. It does not catch States.DataLimitExceeded or States.Runtime. States.DataLimitExceeded can be caught or retried only by naming it explicitly, and States.Runtime is not retriable and always fails the execution.
States.TaskFailed also works as a wildcard and matches any error except States.Timeout. States.Timeout is reported when a Task runs longer than TimeoutSeconds or misses a heartbeat for longer than HeartbeatSeconds. For Lambda tasks, AWS advises handling Lambda.ServiceException and Lambda.SdkClientException.
Where the exam catches people
- Believing Step Functions picks the most specific retrier: it uses the first match in array order, so a
States.TaskFailedretrier listed first takes a custom error. - Believing
MaxDelaySecondsspreads out simultaneous retries: it only caps the wait.JitterStrategyset toFULLrandomizes it. - Believing a catcher keeps the state input by default: in JSONPath the default
ResultPathof$replaces the input with the error output. - Believing
States.ALLcatches everything: it does not catchStates.RuntimeorStates.DataLimitExceeded. - Believing
States.TaskFailedcovers timeouts: it matches any error exceptStates.Timeout.