Use this when a job must stop at the first serious error.
Fail Fast
Fail fast stops a job at the first serious error, such as set -e in Bash or $ErrorActionPreference = 'Stop', so it does not continue in an unknown state and do more damage.
1. Fail fast on unexpected errors to avoid damage.
2. Stop rollouts early.
3. Validate early.
4. Clear message.
5. Better than continuing in an unknown state.
error → stop immediately → report
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Verification path Verify boundary
The negative fixture should deliberately exercise risks such as ambiguous target identity, stale inputs, partial success, unsafe retry, permission drift and confusing tool completion with target-evidence of the actual state, choosing the cases most relevant to which invariant triggers immediate abort, cancellation of remaining work, evidence preservation and preventing partial state from being reported as success.
Step 2 Example Narrow the fault
set -euo pipefail
Ansible: any_errors_fatal: true.
Step 3 Common mistakes Narrow the fault
- Continuing after a failed precondition.
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
- set -e, $ErrorActionPreference = 'Stop'.
- Prevents running in unknown state.
- Combine with cleanup.
set -euo pipefail— Bash$ErrorActionPreference = 'Stop'— PowerShell- any_errors_fatal / max_fail_percentage — Ansible
ReferenceWhy it matters1 section · depth on demand
What it is
Fail fast means stopping at the first serious error instead of continuing with bad state.
ReferenceImportant terms & boundaries2 sections · depth on demand
In depth
Fail fast means stopping at the first sign that a run cannot succeed — invalid input, missing credentials, an unreachable dependency — before any change has been made. It saves time and, more importantly, avoids leaving systems half-changed because a problem was discovered halfway.
Where to fail fast:
- Argument and input validation.
- Credential and connectivity checks against all targets.
- Required tools and versions present.
- Precondition checks on target state.
The opposite principle applies to independent targets once work has started: one failed host should usually not stop work on others (fail fast per target, not globally), unless the change carries shared risk.
set -euo pipefail
command -v jq >/dev/null || { echo "jq missing"; exit 127; }
[[ -n "${API_TOKEN:-}" ]] || { echo "API_TOKEN not set"; exit 2; }
Mechanics
The linked authority for bounded mechanics is Microsoft Azure Architecture Center — Retry pattern; documentation support is separate from observed lab/production Evidence.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in Error Handling > Fail Fast. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://learn.microsoft.com/en-us/azure/architecture/patterns/retry · confidence 94%Deep reference
Healthy vs suspicious evidence
Output interpretation
For which invariant triggers immediate abort, cancellation of remaining work, evidence preservation and preventing partial state from being reported as success, prefer typed fields and stable IDs over human presentation text.