Skip to content

fix: exclude errored code scanning analyses from migration#1529

Open
lindluni wants to merge 3 commits intogithub:mainfrom
lindluni:lindluni/code-scanning-exclusion
Open

fix: exclude errored code scanning analyses from migration#1529
lindluni wants to merge 3 commits intogithub:mainfrom
lindluni:lindluni/code-scanning-exclusion

Conversation

@lindluni
Copy link

@lindluni lindluni commented Mar 19, 2026

Filter out code scanning analyses with non-empty error fields when listing analyses from the source repository, preventing failed analyses from being migrated to the target repository.

When the migrate-code-scanning-alerts is invoked, it used the ListAnalyses API. The results objects in the returned array have an error field. If on the initial upload the SARIF failed to process, the error field is populated. When we try to GetAnalysis to retrieve the SARIF content, we get a 422 Unprocessable Entity because the results retrieval system can't process the SARIF. The GEI CLI fails at that point, instead of skipping that particular result.

We've also built and tested this locally against a production migration and confirmed this works as intended.

  • Did you write/update appropriate tests
  • Release notes updated (if appropriate)
  • Appropriate logging output
  • Issue linked
  • Docs updated (or issue created)
  • New package licenses are added to ThirdPartyNotices.txt (if applicable)

Filter out code scanning analyses with non-empty error fields when listing
analyses from the source repository, preventing failed analyses from being
migrated to the target repository.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Brett Logan <lindluni@github.com>
Copilot AI review requested due to automatic review settings March 19, 2026 17:49
Clarified the bug fix description for `migrate-code-scanning-alerts` to specify exclusion of analyses with processing errors on initial uploads.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR prevents migrate-code-scanning-alerts migrations from failing on code scanning analyses that have an error present in the List Analyses API response by filtering those analyses out before attempting SARIF retrieval.

Changes:

  • Filter out code scanning analyses whose error field is non-empty when listing analyses.
  • Add unit test coverage for excluding errored analyses.
  • Add a release note entry describing the bug fix.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/Octoshift/Services/GithubApi.cs Filters out analyses with a non-empty error field before building CodeScanningAnalysis results.
src/OctoshiftCLI.Tests/Octoshift/Services/GithubApiTests.cs Adds a test ensuring analyses with populated error are excluded from results.
RELEASENOTES.md Documents the behavior change for migrate-code-scanning-alerts.

@github-actions
Copy link

github-actions bot commented Mar 19, 2026

Unit Test Results

    1 files      1 suites   10m 24s ⏱️
1 031 tests 1 031 ✅ 0 💤 0 ❌
1 032 runs  1 032 ✅ 0 💤 0 ❌

Results for commit 5288951.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

Code Coverage

Package Line Rate Branch Rate Complexity Health
ado2gh 71% 70% 737
bbs2gh 83% 78% 663
gei 81% 73% 608
Octoshift 84% 73% 1811
Summary 81% (7939 / 9824) 73% (1947 / 2649) 3819

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