Skip to content

fix: treat score 0 as a successful scan exit - #740

Open
l46983284-cpu wants to merge 2 commits into
controlplaneio:masterfrom
l46983284-cpu:fix/score-zero-exit-code
Open

fix: treat score 0 as a successful scan exit#740
l46983284-cpu wants to merge 2 commits into
controlplaneio:masterfrom
l46983284-cpu:fix/score-zero-exit-code

Conversation

@l46983284-cpu

Copy link
Copy Markdown

Description

Closes #580

A scan that scores exactly 0 already prints Passed with a score of 0 points, but the CLI still exited with the failure code (2 by default). That made score 0 look like a pass in the message and a fail in shell/CI automation.

Maintainer direction on the issue: treat score 0 as a pass with exit 0.

Changes

  • Exit non-zero only when any report score is negative (Score < 0), not <= 0
  • Align the local bats helper assert_zero_points with success for score 0
  • Rename score-0 CLI test titles that call assert_zero_points so they no longer say “fails …” after the exit-code flip

Test plan

  • go test ./pkg/ruler/ -count=1
  • Rebuild CLI and check:
    • score 0 fixture → message Passed, exit 0
    • score 1 fixture → exit 0
    • negative score fixture → exit 2

Score 0 already produces "Passed with a score of 0 points" but the CLI
treated it as failure (exit 2). Exit non-zero only for negative scores.

Closes controlplaneio#580

Signed-off-by: Alex Chen <l46983284@gmail.com>
After treating score 0 as exit success, titles that still said
"fails …" while calling assert_zero_points were misleading.

Signed-off-by: Alex Chen <l46983284@gmail.com>
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.

Return codes inconsistent with scan results

1 participant