Handle Dosya CLI exit codes
Branch scripts on Dosya CLI exit codes, preserve stderr, and distinguish usage, authentication, network, permission, and maintenance failures.
Last reviewed
Dosya CLI uses stable process statuses for automation: 0 success, 1 generic failure, 2 usage, 3 authentication, 4 network, 5 forbidden, and 75 maintenance. Signal exits remain 130 for SIGINT and 143 for SIGTERM.

Before you start
- Capture stdout, stderr, and
$?separately. Routine text and JSON use stdout; diagnostics, warnings, debug output, and progress use stderr. - Decide which classes the job may retry. Authentication and permission failures need correction, not a tight retry.
- A 503 response with code
surface_disabledmaps directly to maintenance exit 75.
Steps
- Run the command without piping stdout directly into another process; first preserve both streams and the original exit status.
- Treat 0 as command success. When a batch command was invoked with
--json, one or more failed members normally produce command-specific JSON and exit 1; parse that receipt to retain successful counts and failure details. - Map 2 to invalid command syntax or arguments, 3 to a missing or rejected credential, and 5 to an authenticated caller lacking permission.
- Map 4 to transport or connectivity failure. Apply bounded retry only when the command itself is safe to repeat.
- Map 75 to temporary maintenance, including
surface_disabled. Reschedule after an operator-approved delay rather than treating it as a permanent configuration error. - Record stderr and the numeric status. Preserve 130 and 143 as cancellations so a scheduler does not mislabel an interrupted job as application failure.

Expected result
Automation branches on the original numeric status, retains human-readable diagnostics from stderr, and never parses an error message to guess whether failure was usage, auth, network, forbidden, or maintenance.
Troubleshooting
A pipeline reports the parser’s status. Save the Dosya process status before invoking jq, or enable shell pipeline-status handling deliberately.
Exit 1 has little detail. Inspect stderr; it is the generic class for failures that do not map to a narrower status.
A retry could mutate data twice. Verify remote state first. An exit code identifies the failure class, not whether the server committed before the connection ended.
Related guides
Was this helpful?
Loading helpfulness results…
Voting saves a necessary ballot cookie for up to 180 days so you can change your answer.
Questions and replies
Ask about the steps in this guide. Questions are reviewed before publication.
Keep account details, credentials and private files out of public questions. Use private support for those.
Loading questions…
Sign in to your Dosya account to ask a question.