Skip to content
On this page

Reference

Exit codes

What the sim workflows source and sim workspaces source commands exit with, and what to run next.

The sim workflows source and sim workspaces source commands exit with a code a script or CI job can branch on. Findings print on stderr, and the result of a command goes to stdout. A code of its own is set aside for each outcome a script handles differently, so test for the code you act on, not for any non-zero status.

status is the command to branch on: it exits 0 when nothing differs, 11 when only your edits are unsaved, and 12 when the server changed since the directory was read.

Code
sim workspaces source status --dir workspace --output json > status.json
case $? in
  0)  echo "in sync" ;;
  11) echo "local edits to apply" ;;
  12) echo "the workspace changed in Sim since the get" ;;
  *)  echo "status failed"; exit 1 ;;
esac

Codes

The table for the kind of directory you work in. Both are built from the table --help, the generated CLI reference and .sim/AGENTS.md print, so they cannot disagree with the CLI.

CodeMeaningWhat to do
0Applied or created, a dry run or check with no errors, or a clean statusGo on
1The source has errors (each printed as file:line:column with a hint), a locked block (E_APPLY_LOCKED_BLOCK), a name another workflow holds (SOURCE_NAME_TAKEN), a --run test run that did not complete, a cancelled prompt, or the command failedFix what it printed and run it again
5Stale (SOURCE_STALE, or E_APPLY_STALE on a dry run): the server changed what this directory was read from, and nothing was writtensim workflows source get --dir <fresh dir>, reapply your edit there, dry-run, apply
6A workflow or its folder is locked (E_APPLY_LOCKED); a locked block exits 1 insteadAsk someone to unlock it in the workflow builder
7The source is over the size limits (on a get, status or diff too)Split function code, or remove blocks or resources
8sim workspaces source apply stopped part-way: what was written is saved into the directoryApply again until it exits 0
9Still rate limited (HTTP 429) after the CLI's retries (up to 6, at most a minute apart); nothing more was writtenWait a minute and run the same command again
10Busy: another apply is writing the workspace (SOURCE_BUSY), or another sim command is using this directory (SOURCE_DIR_BUSY); nothing was writtenRun it again once the other finished
11status: only your edits, which applying writesDry-run, then apply
12status: the server changed since the get (drift, or a conflict with your edits)Follow the Next: line it prints
13Not logged in, the login expired, or the server refused the credential (AUTH_REQUIRED); nothing was sentsim login, or fix or unset SIM_API_KEY when the key comes from it; then the same command again
14apply or create without --yes and no terminal to ask: it printed the plan, found no errors, and wrote nothingRun the same command with --yes
15sim workspaces source apply (or --to) wrote part of its plan and held the rest back: a change that uses a declared secret the workspace has no value for, or a credential key nothing binds to. Its dry run exits 15 too, so a script can tell beforehand that the apply would write only partSet the secret (sim secrets set) or connect the credential, then apply again
130Interrupted (Ctrl-C). An apply or create already sent is finished and saved into the directory first, waiting up to 60s for its answer; a second Ctrl-C, or no answer by then, stops at once and prints that it may have been writtensim workflows source status --dir .

Exit 9 follows the CLI's retries: it resends a request the API answered 429 only when sending it twice is safe, which includes every GET, a source apply and a create. See Scripting for the retry schedule and the codes every command shares (13 and 9).

Was this helpful?
Suggest an edit