Skip to content

CM-68642: stop SCA scan on restore command failure with --stop-on-error#495

Open
omer-roth wants to merge 1 commit into
mainfrom
CM-68642-sca-dependency-path-missing-in-cli-ui
Open

CM-68642: stop SCA scan on restore command failure with --stop-on-error#495
omer-roth wants to merge 1 commit into
mainfrom
CM-68642-sca-dependency-path-missing-in-cli-ui

Conversation

@omer-roth

Copy link
Copy Markdown
Collaborator

Problem

A restore command failing with a non-zero exit code (e.g. poetry lock exit 1) did not stop the scan, even with --stop-on-error.

Root cause — failure-sentinel mismatch:

  • shell() signals a non-zero exit by returning None (catches CalledProcessError, logs, returns None).
  • execute_commands dropped that None via if command_output: and joined an empty list into '' — an empty-string success.
  • try_restore_dependencies only checks if output is None, so '' was treated as success and a Document was returned.
  • restore() therefore never returned None, making the --stop-on-error escalation in _try_restore_dependencies unreachable for a clean non-zero exit.

Fix

execute_commands now treats shell()None as a failed command and returns None (short-circuiting remaining commands). Propagation is restored: fail → None all the way up → FileCollectionError raised under --stop-on-error.

Tests

Existing stop-on-error tests all mocked execute_commandsNone, so they never covered the production path where a real non-zero exit produced ''. Added:

  • TestExecuteCommands — real execute_commands with only shell() mocked: fail→None, short-circuit at first failure, empty-output success ≠ failure, joins outputs.
  • test_shell_failure_propagates_to_none_and_no_lockfile — e2e through try_restore_dependencies.

All 27 SCA restore/collector tests pass.

🤖 Generated with Claude Code

execute_commands swallowed a non-zero restore exit (shell() returns None)
into an empty-string success, so restore() never returned None and the
--stop-on-error escalation in _try_restore_dependencies was unreachable.
Treat a None from shell() as a failed command and propagate None.

Add tests exercising the real execute_commands with only shell() mocked,
covering the failure sentinel the previous mocked tests skipped.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@omer-roth omer-roth requested a review from avishaiamiel as a code owner July 14, 2026 12:31

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.

Tip: disable this comment in your organization's Code Review settings.

@omer-roth omer-roth enabled auto-merge (squash) July 14, 2026 13:05
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.

1 participant