Skip to content
Latchkey

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.

Snyk
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

  1. Fix the real issues Snyk lists.
  2. Set --severity-threshold so only meaningful severities gate.
  3. Ignore accepted findings deliberately via Snyk policy.
.github/workflows/snyk.yml
- 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.

.github/workflows/snyk.yml
- 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-code

How 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.

Frequently asked questions

What causes "snyk code test exit 1"?
By default all severities fail the test; real findings cause the non-zero exit.
How do I fix snyk code test exit 1?
Set a severity threshold and triage

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card