Skip to content

Honor --stop-on-error on cycode scan - #565

Merged
omer-roth merged 4 commits into
cycodehq:mainfrom
WaleedMahamid:CM-8445-fix-scan-stop-on-error
Oct 5, 2026
Merged

omer-roth merged 4 commits into
cycodehq:mainfrom
WaleedMahamid:CM-8445-fix-scan-stop-on-error

Conversation

@WaleedMahamid

Copy link
Copy Markdown
Contributor

What changed

  • scan_command now passes stop_on_error to apply_sca_restore_options_to_context.
  • Removed the now-redundant ctx.obj['stop_on_error'] = stop_on_error assignment, since the helper sets it.
  • Added a regression test that invokes the real scan command, intercepts it at get_scan_cycode_client, and asserts stop_on_error is still set in the context (parametrized for flag on and off).

Why

--stop-on-error has had no effect on cycode scan since it was introduced in #416 (first released in v3.12.1). The command wrote the flag into ctx.obj, then called apply_sca_restore_options_to_context(ctx, no_restore, gradle_all_sub_projects, maven_settings_file). That helper's stop_on_error parameter defaults to False and writes ctx.obj['stop_on_error'], so the user's value was reset before the scan ran. cycode report sbom path already passes the flag and was not affected.

Customer-reported (support ticket #8445). Repro: a requirements.txt with an unresolvable package, then cycode scan -t sca --stop-on-error path . exits 1 with a restore warning instead of exiting 2.

Notes for reviewers

  • With the flag preserved, a failed restore raises FileCollectionError, handle_scan_errors sets did_fail, and scan_command_result_callback exits with SCAN_ERROR_STATUS_CODE (2). That path already had unit coverage; only the context wiring was broken.
  • The new test fails on main and passes with this change. The scan command and SCA file collector suites (211 tests) pass, and ruff is clean.

🤖 Generated with Claude Code

The scan command stored stop_on_error in the context, then called
apply_sca_restore_options_to_context without it. The helper's parameter
defaults to False and overwrites ctx.obj['stop_on_error'], so the flag
never took effect on `cycode scan`. Pass it through, as
`cycode report sbom path` already does, and drop the redundant assignment.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@omer-roth omer-roth left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

fix tests

WaleedMahamid-Cycode and others added 2 commits October 5, 2026 08:48
The scan package re-exports a scan_command function that shadows the
submodule. Python 3.9's mock.patch resolves dotted targets with getattr,
so it found the function instead of the module. Patch the module object
fetched with importlib.import_module instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread tests/cli/commands/scan/test_scan_command.py Outdated
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@WaleedMahamid

Copy link
Copy Markdown
Contributor Author

comments resolved

@omer-roth
omer-roth merged commit be44c9d into cycodehq:main Oct 5, 2026
26 checks passed
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.

3 participants