Skip to content

fix: return distinct exit code 2 on internal errors#7468

Open
raajheshkannaa wants to merge 1 commit intobridgecrewio:mainfrom
raajheshkannaa:fix/exit-code-internal-errors
Open

fix: return distinct exit code 2 on internal errors#7468
raajheshkannaa wants to merge 1 commit intobridgecrewio:mainfrom
raajheshkannaa:fix/exit-code-internal-errors

Conversation

@raajheshkannaa
Copy link
Copy Markdown

Closes #7393

Summary

  • Internal errors (API failures, JSON decode errors in get_public_run_config) now return exit code 2 instead of being silently swallowed
  • Added --no-fail-on-crash flag support: returns 0 on internal errors when set
  • Scan continues after internal errors so partial results are still reported (behavioral improvement over previous immediate termination)

Exit code semantics

Code Meaning
0 All checks passed (or soft-fail)
1 One or more checks failed
2 Internal error during scan

When --no-fail-on-crash is set, internal errors return 0 instead of 2. Check failures (exit 1) still take precedence over suppressed internal errors.

Test plan

  • 7 new tests covering: normal run, report errors, unhandled exceptions, --no-fail-on-crash override, platform integration flag, exit code helper
  • All existing exit code tests pass

When checkov encounters internal errors (e.g., failed API calls to
get mappings/guidelines, report errors), it now returns exit code 2
instead of silently continuing with exit code 0.

Exit code semantics:
- 0: all checks passed (or soft-fail)
- 1: one or more checks failed
- 2: internal error occurred during the scan

The --no-fail-on-crash flag still suppresses exit code 2 to 0.
Internal errors are tracked via _internal_error_occurred flag on the
Checkov instance and internal_error_occurred on bc_integration, so
errors caught silently (like get_public_run_config JSON decode failures)
are properly surfaced in the exit code.

Closes bridgecrewio#7393
@raajheshkannaa
Copy link
Copy Markdown
Author

Hi, could a maintainer approve the CI workflow run? The security scan check appears to be waiting for approval since this is an external contributor PR. Thanks!

@raajheshkannaa
Copy link
Copy Markdown
Author

Friendly bump. CI workflow has been waiting for maintainer approval since March 17. Could someone approve the workflow run so CI can validate this? Happy to address any feedback once tests run.

@raajheshkannaa
Copy link
Copy Markdown
Author

Friendly bump. CI workflow approval is still pending. Could a maintainer approve the workflow run? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement exit code on internal errors

1 participant