When something goes wrong
Branch on the exit code. Do not grep the message: the codes are fft's contract with scripts, and the wording is not.
| code | what happened | what to do |
|---|---|---|
| 0 | it worked | — |
| 1 | unclassified failure | read stderr; it says what broke |
| 2 | bad flags or arguments | your mistake, not the API's. Re-read --help. Do not retry |
| 3 | no active project, or the config is unusable | fft project list. Ask the user; do not invent a project |
| 4 | authentication failed | the credentials are wrong or expired. Tell the user. Do not re-prompt for a password |
| 5 | authenticated, but not permitted | usually the user's role lacks the permission: fft api describe <op> names it, fft auth whoami says what they have. Unless the message starts a proxy or gateway between fft and the tenant refused the request — then the tenant never saw it, and the fix is the proxy (HTTPS_PROXY/NO_PROXY), not the account |
| 6 | not found | the id does not exist. Check it before assuming the endpoint is wrong |
| 7 | version conflict (409) | the object changed under you. Re-read it, re-apply, re-send. Never retry the same body |
| 8 | partial bulk write | some items landed. Read the per-item results; re-send only the FAILED ones, never the UNKNOWN ones |
| 9 | upstream unreachable or erroring | a 5xx, a transport failure (connection refused or reset, DNS, TLS, a proxy that is down and refuses the CONNECT with a 5xx) or a timeout (--timeout). fft retried it only if it was safe to repeat — see below. Back off, and tell the user |
| 10 | read-only: fft refused a write | nothing was sent. Not an auth problem, and not routable around. Ask the user |
| 11 | a check ran and found problems | fft network check worked, and its answer is the findings on stdout. Read them (-o json for the rule ids); fixing the network is its owner's decision, so report them rather than change connections |
| 130 | interrupted | — |
Exit 9 on a create: it may have landed anyway
fft retries only what is safe to send twice — GET, PUT, DELETE. A POST or a PATCH is sent once, because a 500 on POST /api/facilities does not mean the facility was not created; it means nobody told you whether it was.
So a create that exits 9 — including one that timed out — is not a create that failed. It is a create with an unknown outcome, and re-running it is how you end up with two of something:
fft facility list --tenant-facility-id BER-01Go and look before you send it again. (This is the same fact the bulk writers report as UNKNOWN — see recipes.md.) Note also that the API's searches are POSTs, so a failed list is not retried either — but a list is safe to simply run again.
The three refusals you will be tempted to "fix" wrongly
Exit 2 after a destructive command was refused. Your shell is not a terminal, so fft would not prompt, so it refused. Do not reach for --yes to make the error go away. --yes is the user's consent, not yours: go and ask them, and let them decide.
Exit 10, read-only. Do not add --read-only=false. It is refused on purpose — the flag can tighten and never loosen, and trying is itself a usage error. The project is protected because somebody protected it. Ask.
Exit 4, authentication. Do not ask the user to type a password into the chat, and do not re-run fft project add to "refresh" it. fft auth refresh is the command; if it fails, the credentials themselves are the problem and the user has to fix them.
Exit 3, "no OS keychain is available"
This is the machine, not the credentials. There is no keychain for fft to store anything in — commonly WSL, a container, or a headless Linux box, where nothing owns the D-Bus Secret Service. Retrying will fail identically, and nothing is wrong with the user's password.
Do not re-prompt for credentials, and do not run fft auth refresh — there is nothing to refresh into. Do not silently add --no-keyring on the user's behalf either: it stores their password and refresh token in a cleartext 0600 file, which is theirs to agree to.
Tell them what the error already says, and let them pick:
fft project add prd --base-url https://acme.api.fulfillmenttools.com --no-keyring…or noKeyring: true under settings: in ~/.config/fft/config.yaml to make it stick, or gnome-keyring plus a session D-Bus to keep a real keychain. On a terminal, fft project add asks this question itself and remembers the answer.
Diagnosing
fft ping
fft auth whoami
fft project currentfft pingneeds no credentials. It tells "the tenant is down" (exit 9) apart from "my token is wrong" (exit 4).fft auth whoamiprints the permissions the current credentials actually have. It is the answer to an exit 5 about permissions — but not to an exit 5 (or a 401) whose message says a proxy or gateway refused the request, nor to an exit 1 saying the proxy refused to connect: the tenant never answered those, so the account's permissions are not the cause. CheckHTTPS_PROXY/NO_PROXYand ask whoever runs the proxy.--debugon any command dumps the request and the response to stderr, secrets redacted.
A 400 that says nothing useful
Usually a body missing a required field. Do not guess at it:
fft api describe addPickJob
fft api addPickJob --exampleThe sample body carries every required field, and describe lists every parameter.
"Query too complex"
Exit 1: the API returned HTTP 400: Query too complex - please simplify your search criteria or reduce the result set size. Any search can hit it on a tenant with a very large collection, and the API's own advice is the part that does not work: a smaller --size fails the same way, because the cost is in the filter or sort over the whole collection, not in the page.
Narrow the query instead: filter on an exact match (an id or a tenant id), and drop any date range and the sort. In an --all walk the message says how many pages and items were read before the refusal; nothing is printed, because half a list is not the list. For orders the exact-match filter is fft order search --tenant-order-id <id>, and fft routing decision-logs in practice lists the newest routings first (the API does not guarantee an order).
"there is no operation X"
Exit 2, with a suggestion. The operationId is wrong — find the right one:
fft api list --search pick