Snyk Code "snyk code test" issues fail the build in CI
Like other Snyk test commands, snyk code test exits with code 1 when it finds issues meeting the severity threshold. The job fails by design; the output lists the issues and their severities.
What this error means
The Snyk Code step ends with issues listed and exit code 1, failing the workflow, even though the scan ran successfully.
Testing app...
x [High] Hardcoded Secret
x [Medium] SQL Injection
2 Code issues found. Snyk exited with code 1.Common causes
Issues at or above the threshold were found
By default all severities fail the test; real findings cause the non-zero exit.
A finding you intend to accept still fails the gate
Without a threshold or ignore, even a low-severity or accepted finding fails the job.
How to fix it
Set a severity threshold and triage
- Fix the real issues Snyk lists.
- Set
--severity-thresholdso only meaningful severities gate. - Ignore accepted findings deliberately via Snyk policy.
- run: snyk code test --severity-threshold=high
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}Report to Code Scanning without failing early
Emit SARIF and upload it, using continue-on-error so the gate is the code scanning result, not a hard CLI exit.
- run: snyk code test --sarif-file-output=snyk.sarif
continue-on-error: true
- uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: snyk.sarif
category: snyk-codeHow to prevent it
- Choose a severity threshold matched to your policy.
- Manage accepted findings through Snyk ignore policy, not by disabling the scan.
- Decide whether the CLI exit or the SARIF upload is the gate.