Valkyrian Labs logo

Exit codes

The stable error codes and the exit status each one maps to.

Exit codes

Every failure has a stable error code (error.code in the --json envelope), and the exit status follows from it. forti and forti-mcp share the same codes.

Exit statuses

ExitCodesIn short
0nonesuccess
1internala bug or an unexpected state
2usagethe command line or request is wrong
3configthe local setup is wrong
4connection, auththe device could not be reached, or refused the key
5not_found, unknown_resourcean object, a stored plan, a resource or forti-mcp does not exist
6validation, apithe device or the catalog rejected the request
7stale_plan, approval_required, policy_deniednothing was changed: plan again, approve, or change the mode
8partial_failure, management_connectivity_lost, outcome_unknownan apply stopped and the device may have changed

Error codes

ExitCodeMeaningTypical fix
1internala bug or an unexpected statereport it, with --json output
2usagebad arguments or request shapeforti <command> --help
3configmissing or invalid profile, credentials or config file; an unwritable audit logforti configure, forti doctor
4connectionDNS, connect, TLS or timeoutforti doctor; --ca-bundle, --resolve-ip, --port
4authHTTP 401/403: the key was rejected (never retried)check the key, trusted hosts, admin profile
5not_foundthe object (or a stored plan, or forti-mcp) does not existcheck the key; forti get <resource> lists objects
5unknown_resourcethe path is not in the catalogforti discover <search>
6validationunknown or read-only attribute, bad valueforti discover <resource>
6apianother FortiOS error (details carry the HTTP status, FortiOS code and CLI messages)read details.cli_error
7stale_planthe device changed since the plan was madeplan again
7approval_requiredapply on a guarded profile without a valid approvalforti plan approve <id>
7policy_deniedthe mode forbids it (read-only), the plan was already applied or failed its integrity check, or a critical plan's backup failedforti profile mode NAME guarded; plan again
8partial_failureapply stopped part-way; the record says what happenedinspect the record and the rollback plan
8management_connectivity_lostapply stopped: the connectivity probe after a critical change failedrestore access through an independent path; see below
8outcome_unknowna change may or may not have reached the devicere-read the object before doing anything else

Error details

error.details adds structure where it helps: reason (for example read_only, already_applied, before_changed, backup_failed), hint, http_status, fortios_error and cli_error from FortiOS, and for a stopped apply the full execution record with the rollback plan.

1{"ok": false, "error": {"code": "not_found", "message": "firewall/address \"x\" not found", "details": {"http_status": 404}}}

After exit 8

The device may have changed

Exit 8 means an apply stopped after it began executing operations. Read the execution record in error.details before doing anything else, then read Applying a plan and Recovery aids are not guaranteed recovery.

forti doctor

forti doctor exits with the status of its first failed check. Warnings do not fail it.