Skip to content

Exit codes

Every witnyx command exits with 0, 1 or 2. Only check exits with 1, and only check and upload give the codes a meaning of their own:

Command 0 1 2
check The check ran, and no --fail-on rule triggered. The check ran, and a --fail-on rule triggered. The check could not run, or it was incomplete and --strict was set.
upload The service recorded the upload, or it did not and --require-upload was not given. Never. The service did not record the upload and --require-upload was given, or the arguments could not be parsed.
init, cache update, schema, version, mcp Done. Never. Could not run: a usage error, an input error or a failed download.

Each command’s page lists its exit codes too, from the same reference as --help --format json.

For check, 0 means that no --fail-on rule triggered. It does not mean that nothing was found: a warning, such as a component past its end of life, fails the build only when a rule names it.

Terminal window
$ witnyx check bom.json
[PASS] No actively exploited vulnerabilities found
[WARN] 1 component past end of life

An incomplete check also exits with 0 unless --strict is set (see Incomplete checks). The report says so: read result.status in the JSON report, or the [INCOMPLETE] line of the text report, as well as the exit code, and never describe an incomplete check as passing.

For upload, 0 also covers an upload that the service did not record, because a failed upload never blocks a deploy unless --require-upload is given. Read the warning on standard error, or status in the upload document.

Only check exits with 1: the check ran, and at least one --fail-on rule triggered. It is a result, not a tool failure, and result.triggeredBy in the JSON report lists the rules. Without --fail-on and without failOn in .witnyx.yml, the one rule is exploited: the build fails on an actively exploited vulnerability that no one assessed as not affecting the product.

Terminal window
$ witnyx check bom.json
[FAIL] 1 actively exploited vulnerability — build failed

A rule that triggered wins over an incomplete check: with --strict, the exit code is still 1.

The command could not run: a usage error, a missing or broken software bill of materials (SBOM), a broken configuration file, or a failed download in cache update. Standard error says why, with an error code that Error codes explains. Arguments that cannot be parsed are the exception: a person gets the parser’s message and the usage instead. For check in agent mode, and in every file that --output json=PATH names, the error document takes the place of the report.

check --strict also exits with 2 when the check is incomplete and no rule triggered. It still writes the normal report, with result.exitCode 2, not the error document. A check with --offline is always incomplete, because OSV has no offline copy, so --offline --strict never exits with 0. With an empty cache:

Terminal window
$ witnyx check bom.json --offline --strict
[INCOMPLETE] 3 components not checked (osv: offline mode; cisa-kev: No cached CISA KEV data available for offline use)

upload exits with 2 only when the service did not record the upload and --require-upload was given, or when its arguments could not be parsed.

A check is incomplete when one of its two required sources gave no usable answer: OSV, for known vulnerabilities, or CISA’s Known Exploited Vulnerabilities catalogue. That happens when a source cannot be reached or its answer cannot be used, when the --timeout budget runs out, with --offline, and when no component has a package URL with a version, so that OSV cannot be asked. ENISA’s list and endoflife.date are not required: when they fail, the report adds a note instead.

The check Without --strict With --strict
is complete, and no rule triggered 0 0
is incomplete, and no rule triggered 0 2
triggered a rule, complete or not 1 1

Set --strict where a check that could not look at every component must stop the build, for example before a release.

See also: Choose when the build fails and Complete and incomplete checks.

Witnyx is a record-keeping and workflow tool. It does not certify compliance. Nothing on this site is legal advice.