> For the complete documentation index, see [llms.txt](https://cortex-docs.paloaltonetworks.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cortex-docs.paloaltonetworks.com/cortex-cloud-posture-management/cortex-cli/exit-codes-and-error-handling.md).

# Exit codes and error handling

The Cortex Unified CLI has standardized exit codes categorized by application states, error suppression flags, and specific modules. Use this guide to configure and troubleshoot your CI/CD pipelines.

### Standard CLI exit codes

| Exit Code | Constant / Representation                | Description                                                                                                                                                                 |
| --------- | ---------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **`0`**   | `ScanSuccess`                            | The scan executed successfully and no security findings were found                                                                                                          |
| **`1`**   | `ScanFailed`                             | The scan completed with findings (e.g., findings blocked by AppSec policy), or a general operational failure occurred                                                       |
| **`2`**   | `ScanExecutionFailure` / `InternalError` | An execution error occurred, version mismatch was detected (local version is strictly greater than the backend version), or a CLI usage/configuration error was encountered |

***

### Exit code suppression flags

The CLI provides two global flags to control and suppress exit codes in automated environments:

* **`--soft-fail`**: Converts exit code **`1`** (findings with blocking policy) to **`0`**
* **`--no-fail-on-crash`**: Converts exit code **`2`** (internal/execution error) to **`0`**

### Module-specific exit codes

#### Attestation module

* **`1` (`exitOperationFailed`)**: Returned when a cryptographic or attachment operation fails (e.g., signing failed, verification failed, register/delete/update key failed, failed to render output).
* **`2` (`exitUsageError`)**: Returned for user configuration/usage errors (e.g., missing required flags like `--image` or `--key`, invalid flag values).

#### Code security module

* **`2` (`casExtractErrorCode`)**: Returned when the runner fails to extract the underlying APPSEC engine, failed to acquire lock, failed to validate signature, or during timeout execution.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://cortex-docs.paloaltonetworks.com/cortex-cloud-posture-management/cortex-cli/exit-codes-and-error-handling.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
