Skip to content

Fail scan comparisons with missing or invalid package lists - #461

Merged
lelia merged 7 commits into
mainfrom
fix/null-diff-artifacts-exit-3
Nov 24, 2026
Merged

lelia merged 7 commits into
mainfrom
fix/null-diff-artifacts-exit-3

Conversation

@dc-larsen

@dc-larsen David Larsen (dc-larsen) commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Behavior

A diff-scans response with a comparison object must include the five package lists. Missing or invalid lists report an infrastructure failure in standard and strict modes. The CLI accepts unchanged: null when it requested omit_unchanged. A response without a comparison object, such as HTTP 204, can still use the streaming fallback.

The default exit code is 3. --exit-code-on-api-error can remap it, and --disable-blocking takes precedence.

Verification

  • CLI regressions exercise the poll response through the real command path and check exit policy, streaming fallback, and report generation.
  • Parser tests cover empty and malformed results, omitted unchanged artifacts, and an HTTP 204 through the SDK.
  • Unit and core tests, Ruff, lockfile validation, and wheel and sdist checks passed.

Release

Ships in 2.14.0. Merge order: #461 → #462 → #460 → #464 → #465 → #463. Merged together in that order on main at #459, the six pass the full test suite and ruff check. main requires branches to be up to date, so update each PR from main after the previous merge. CHANGELOG.md will conflict each time: combine the bullets under the existing ## 2.14.0 subsections (Upgrade notes, Changed, Fixed, Documentation) by hand rather than taking either side.

This is 1 of 6. Merge it first: it changes the comparison path the other five run through, and #462's test fixture already expects its validation.

Review focus. The CLI validates completed diff-scans results in standard and strict mode. If the API returns a valid package-list shape that the CLI rejects, affected jobs fail before findings with exit 3 by default. Before tagging 2.14.0, verify live cached comparisons with omit_unchanged enabled and with unchanged artifacts included.

Public Changelog

Comparisons with missing or invalid package lists fail with exit 3 by default. The existing infrastructure-error exit flags apply.


Refs: CE-499

When the diff-scan poll returned a finished comparison whose artifacts
were null and whose incomplete flag was unset, get_diff_scan_artifacts
raised a plain Exception. get_added_and_removed_packages treated that
like any other failure of the diff-scans flow and fell back to the
streaming comparison, whose response has no incomplete flag. The run
then reported on a comparison nobody had checked for completeness.

A finished comparison without an artifacts object now raises
IncompleteComparisonError, which skips the fallback and maps to the
infrastructure exit code (3, --exit-code-on-api-error, or 0 under
--disable-blocking). Failures of the flow itself (missing token scopes,
transient errors, the polling timeout, a truncated response) still fall
back to streaming as before.
@lelia lelia changed the title Fail with exit 3 when a scan comparison returns no artifacts Fail with exit 3 when a scan comparison returns no artifacts Nov 20, 2026
@lelia lelia self-assigned this Nov 20, 2026
The SDK's diffscans.get returns {} for statuses it doesn't raise on (204, an
unfollowed 3xx). That response says nothing about the comparison, so it falls
back to streaming as it did in 2.13.0 instead of exiting 3 with a message
claiming the API finished the comparison. Only a returned diff_scan whose
artifacts are null, missing or not an object raises the incomplete-comparison
error, and its message now says that.
2.13.2 was released from main, so this change needs the next patch version.
Fail incomplete comparisons before reporting findings. Keep the streaming
fallback when the response has no comparison object.

Group the pending CLI changes under 2.14.0.
@lelia lelia changed the title Fail with exit 3 when a scan comparison returns no artifacts Fail scan comparisons with missing or invalid package lists Nov 24, 2026
@lelia
lelia marked this pull request as ready for review November 24, 2026 02:55
@lelia
lelia requested a review from a team as a code owner November 24, 2026 02:55
@lelia

lelia commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

bugbot run

@cursor

cursor Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

PR Summary

Overview
Unable to generate summary.

Reviewed by Cursor Bugbot for commit 02d777c. Configure here.

@lelia
lelia temporarily deployed to socket-firewall November 24, 2026 02:55 — with GitHub Actions Inactive

@cursor cursor 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.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 02d777c. Configure here.

@lelia
lelia merged commit ce03d4c into main Nov 24, 2026
35 of 45 checks passed

This branch was previously deployed

1 inactive deployment
socket-firewall — 02d777cf Deployed Nov 24, 2026 by lelia via python-sfw-smoke-enterprise #684
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