reliability
What Happens When Step Four Fails
Most workflow tools are built for the path where everything works. The behaviour that matters is what the other path does, and whether anybody is told.
A workflow is a sequence, and the interesting question about any sequence is what the state is when it stops halfway.
Step one creates the record. Step two sends the confirmation. Step three charges the deposit. Step four schedules the crew, and step four fails.
The customer has been charged and nobody is coming. That is not a notification problem. It is a state problem, and the system is now holding a lie: a record that says the job is booked when no crew exists for it.
Three honest options
There are exactly three things a workflow can do with a failed step, and the mistake is having no explicit answer rather than picking the wrong one.
Retry. Correct when the failure is probably transient: a timeout, a 503, a rate limit. Needs backoff with jitter so a shared outage does not become a stampede, which the AWS builders' library piece covers properly. Needs a cap, because a retry loop with no limit is an outage amplifier.
Compensate. Correct when the failure is permanent and earlier steps had side effects. The deposit charge gets refunded or voided, the confirmation gets a follow-up correcting it. This is the expensive option to build and the only honest one when money has moved.
Stop and escalate. Correct when a human needs to decide. The run halts, the state is recorded as halted-at-step-four with the reason, and somebody is told. The important part is the recording: a halted run that looks identical to a completed one is worse than a crash.
What is never correct is the fourth behaviour, which is also the most common: log the error, continue to step five, and finish with a green tick.
Distinguishing the failures
Retrying a permanent failure is just a slower way to fail, and not retrying a transient one throws away work that would have succeeded. So the classification matters, and HTTP gives you most of it for free.
A 429 means you are being rate limited. RFC 6585 defines it, and it normally comes with a Retry-After header telling you how long to wait. Honour the header. Backing off faster than the server asked is the single rudest thing an integration can do, and the common result is a longer block.
A 503 is the service saying it cannot handle this right now. Retry with backoff.
A 500 is ambiguous. It may be transient. It may be your payload triggering a bug that will trigger identically every time. Retry a bounded number of times, then escalate.
A 400 or 422 means your request was wrong. Do not retry. The same request will be wrong again. Record it and escalate, because this is usually a bug in your workflow rather than a failure of the other side.
A 401 or 403 means credentials. Never retry blindly: a loop against an auth failure is how accounts get locked. Escalate immediately, because a human has to fix it and every minute of silence is more work not happening.
RFC 9110 is the current reference for what each of these means.
The dead letter
Runs that failed and could not be recovered have to go somewhere a person looks. If that place does not exist, they go nowhere, and "nowhere" is indistinguishable from "fine".
The useful version has four properties.
Every entry says what the run was trying to do, in the language of the business rather than the stack trace. "Schedule crew for job 4471" beats "TypeError in step 4".
Every entry says what failed and what the other side returned, truncated but not removed.
Every entry can be retried from the point of failure, by a person, after they fix the cause.
The list has a size and somebody sees it. A dead letter queue nobody has opened in three weeks is a database table.
Partial success is the hard case
The genuinely difficult failure is the one where the step both succeeded and failed: the charge went through and the response was lost, the email was sent and the status update was not.
There is no clever solution. There are two serviceable ones.
Make the steps idempotent so that re-running the whole sequence is safe, and then re-run the whole sequence. This is the cleanest answer and it requires every step to be designed for it.
Or order the steps so that the irreversible ones are last. If the deposit charge is the final step, a failure before it leaves an unbooked job and an uncharged customer, which is a recoverable state. If it is the third of five, a failure afterwards leaves a charged customer and no job, which is a refund and an apology.
That ordering rule is free, it is decided when the workflow is drawn rather than when it is debugged, and it eliminates most of the expensive cases before they can happen.
The question to ask of any workflow you run
Not "does it work". Ask: if step three failed right now, what would the system believe, and who would find out?
If the answer to the second half is "the customer", the workflow is not finished.