Skip to content

fix(cli): propagate scan --wfp failure to exit code (SP-4512) - #223

Merged
isasmendiagus merged 2 commits into
mainfrom
fix/SP-4512-wfp-scan-exit-code
Jul 21, 2026
Merged

fix(cli): propagate scan --wfp failure to exit code (SP-4512)#223
isasmendiagus merged 2 commits into
mainfrom
fix/SP-4512-wfp-scan-exit-code

Conversation

@isasmendiagus

@isasmendiagus isasmendiagus commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes SP-4512: scanoss-py scan --wfp <file> always exited 0, even when the scan failed.

The --wfp branch in the scan handler discarded the return value of scanner.scan_wfp_with_options(...), so a failed WFP scan reported success. This was inconsistent with every other scan mode (folder, STDIN, --files, dependency), which map failure to a non-zero exit, and it broke CI pipelines that rely on the exit code to detect failures.

The scan --wfp branch discarded the return value of
scan_wfp_with_options, so a failed WFP scan always exited 0 even though
no results file was produced. This was inconsistent with the folder,
STDIN and dependency scan modes, which map failure to a non-zero exit,
and broke CI pipelines that rely on the exit code to detect failures.

Wrap the call in the same 'if not ...: sys.exit(1)' guard used by the
other scan branches, and add regression tests asserting a failed
--wfp scan exits non-zero and does not leave partial results behind.
@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The scan --wfp command now exits with status 1 when scanning fails. Regression tests verify the exit code and absence of partial output, while package version and changelog entries advance to 1.54.2.

Changes

WFP scan failure handling

Layer / File(s) Summary
WFP failure exit contract
src/scanoss/cli.py, tests/test_scan_wfp_exit_code.py, src/scanoss/__init__.py, CHANGELOG.md
The CLI exits non-zero for failed WFP scans; tests cover failure status and empty output, and release metadata is updated to 1.54.2.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related issues

  • scanoss/scanoss.py issue 220 — Directly addresses WFP scan return-value handling and non-zero failure exits.

Possibly related PRs

Suggested labels: bug

Suggested reviewers: alex-1089, mscasso-scanoss

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: propagating scan --wfp failures to a non-zero exit code.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/SP-4512-wfp-scan-exit-code

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown

SCANOSS SCAN Completed 🚀

  • Detected components: 2
  • Undeclared components: 0
  • Declared components: 2
  • Detected files: 112
  • Detected files undeclared: 0
  • Detected files declared: 112
  • Licenses detected: 1
  • Licenses detected with copyleft: 0
  • Policies: ✅ 1 pass (1 total)

View more details on SCANOSS Action Summary

@mscasso-scanoss mscasso-scanoss left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@isasmendiagus
isasmendiagus merged commit 0c1292b into main Jul 21, 2026
6 checks passed
@isasmendiagus
isasmendiagus deleted the fix/SP-4512-wfp-scan-exit-code branch July 21, 2026 07:32
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.

2 participants