Skip to content

Bug fix for batch size issue (AST-181549) - #1580

Merged
cx-anurag-dalke merged 2 commits into
mainfrom
bug/AST-181549
Oct 5, 2026
Merged

cx-anurag-dalke merged 2 commits into
mainfrom
bug/AST-181549

Conversation

@cx-harshjeet-patil

Copy link
Copy Markdown
Contributor

By submitting this pull request, you agree to the terms within the Checkmarx Code of Conduct. Please review the contributing guidelines for guidance on creating high-quality pull requests.

Description

Description

Fixes a crash in cx scan list (and the VS Code extension'sd whenever a project/branch had more than 50 completedscans.

Root cause: the CLI batched scan IDs in groups of 200 before calling the SAST-metadata backend, which only accepts 50 IDs per request. Any batch
over 50 got rejected with a 400, and a bug in the HTTP wranil, nil) instead of a real error — the caller thendereferenced the nil result, crashing the whole process.

Changes:

  • internal/services/sast-metadata.go: reduced BatchSize from 200 to 50 to match the backend's cap and fixed a race where a batch failure could be silently dropped instead of returned as an error (now aggregates all batch errors via errors.Join).
  • internal/wrappers/sast-metadata-http.go: the 400/500 res error instead of nil; also fixed a response-body leak on a malformed error response.
  • internal/wrappers/mock/sast-metadata-mock.go: added a wa for tests.
  • internal/services/sast-metadata_test.go: new test confirming a failing batch is surfaced as an error, not panicked or swallowed.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Related Issues

https://checkmarx.atlassian.net/browse/AST-181549

Checklist

  • I have performed a self-review of my code
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)
  • Any dependent changes have been merged and published in downstream modules
  • I have updated the CLI help for new/changed functionality in this PR (if applicable)
  • All active GitHub checks for tests, formatting, and security are passing
  • The correct base branch is being used

Screenshots (if applicable)

Add screenshots to help explain your changes.

Additional Notes

Add any other relevant information.

@cx-harshjeet-patil cx-harshjeet-patil changed the title Bug fix for batch size issue Bug fix for batch size issue (AST-181549) Sep 29, 2026
cx-anurag-dalke
cx-anurag-dalke previously approved these changes Oct 5, 2026

@cx-anurag-dalke cx-anurag-dalke 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.

ok

Comment thread internal/services/sast-metadata.go
Comment thread internal/wrappers/sast-metadata-http.go

@cx-anurag-dalke cx-anurag-dalke 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.

ok

@cx-anurag-dalke
cx-anurag-dalke merged commit c476b7d into main Oct 5, 2026
24 of 27 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