Skip to content

Exit codes ​

Every stackorder command exits with one of four codes. Scripts and hooks can rely on them; the reusable workflows do.

CodeNameMeaning
0successThe command did what it was asked.
1errorBad flags or configuration, a failed Terraform or OpenTofu command, a failed hook, a dependency cycle, or a server error that is not a refusal.
2changesA result rather than a failure: affected found affected stacks, or drift found drift.
3refusedThe server refused the request, or the CLI refused to apply because it could not confirm the apply (fail closed).

By command ​

Command0123
resolveResolved, with or without affected stacks, confirmed or unconfirmedScan or config error, cycle, server errorServer refusal, such as superseded
planPlan succeeded, with or without changes, confirmed or unconfirmedinit, plan, show or a hook failedThe server refused the result
applyApplied and reportedApply or post-apply hook failed, reporting failed, usage error (--local in Actions, no run id, no API key)Run or stack not planned, commit mismatch, re-plan differs from the recorded plan, no server in Actions, server unreachable, lock refused
driftNo driftThe drift check failedDrift foundThe server refused the result
checkVerdict recordedUsage error, no run id, no serverThe server refused the verdict
graphGraph printedScan or config error
affectedNo stack affectedScan or config error, cycleAt least one stack affected
unlockEvery named lock released, or none was heldNo server, no API key, unknown repository or stackThe server refused the unlock
versionVersion printed--format dot, which only graph and affected support

How server answers map to exit codes ​

Server answerExit code
2xx0, or 2 for affected and drift results
403 forbidden, 409 conflict, 409 refused, 409 superseded, 423 locked3
401 unauthorized, 400 invalid, 404 not_found, 4131
Network error, timeout or 5xx after three retriesUnreachable: resolve, plan and drift continue with an unconfirmed result and exit as if the call had not been made; apply exits 3

See API errors for the codes themselves.

In workflows ​

The drift action records exit code 2 in its exit-code output and succeeds; any other non-zero code fails the step. The other actions fail their step on any non-zero exit code, so a plan with changes (0) passes and a refused apply (3) fails the job.

In a shell step:

sh
set +e
stackorder affected --base origin/main
code=$?
set -e
case "$code" in
  0) echo "nothing to plan" ;;
  2) echo "stacks affected" ;;
  *) exit "$code" ;;
esac