CM-68642: stop SCA scan on restore command failure with --stop-on-error#495
Open
omer-roth wants to merge 1 commit into
Open
CM-68642: stop SCA scan on restore command failure with --stop-on-error#495omer-roth wants to merge 1 commit into
omer-roth wants to merge 1 commit into
Conversation
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>
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A restore command failing with a non-zero exit code (e.g.
poetry lockexit 1) did not stop the scan, even with--stop-on-error.Root cause — failure-sentinel mismatch:
shell()signals a non-zero exit by returningNone(catchesCalledProcessError, logs, returnsNone).execute_commandsdropped thatNoneviaif command_output:and joined an empty list into''— an empty-string success.try_restore_dependenciesonly checksif output is None, so''was treated as success and aDocumentwas returned.restore()therefore never returnedNone, making the--stop-on-errorescalation in_try_restore_dependenciesunreachable for a clean non-zero exit.Fix
execute_commandsnow treatsshell()→Noneas a failed command and returnsNone(short-circuiting remaining commands). Propagation is restored: fail →Noneall the way up →FileCollectionErrorraised under--stop-on-error.Tests
Existing stop-on-error tests all mocked
execute_commands→None, so they never covered the production path where a real non-zero exit produced''. Added:TestExecuteCommands— realexecute_commandswith onlyshell()mocked: fail→None, short-circuit at first failure, empty-output success ≠ failure, joins outputs.test_shell_failure_propagates_to_none_and_no_lockfile— e2e throughtry_restore_dependencies.All 27 SCA restore/collector tests pass.
🤖 Generated with Claude Code