GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fix `upload-sarif` Action failing if there are no Code Scanning SARIF files by mbg · Pull Request #3123 · github/codeql-action

Conversation

@mbg

@mbg mbg commented Sep 18, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

In #3064, we overlooked that upload_lib.uploadFiles is called in the upload-sarif Action, which will fail if it cannot find any SARIF files matching the predicate it is given.

For a Code Quality only analysis, there are no Code Scanning SARIF files and the call to upload_lib.uploadFiles therefore fails before the Code Quality SARIF file(s) can be uploaded.

This PR refactors the upload-sarif Action so that there's common code for Code Scanning and Code Quality to upload either one file or several matching files.

There are some optional, other changes in this PR as well, which I can remove if needed:

  • The UploadStatusReport values for each SARIF upload are now combined for telemetry if both analysis kinds are enabled. Otherwise, we use the respective UploadStatusReport.
  • I have added a new sarif-ids output to the upload-sarif Action, which contains a stringified JSON object with details of the SARIF ids that we uploaded to different endpoints. Initially I went for just a comma-separated list of IDs, but I thought it would be useful to know which ID is for which service.

Risk assessment

For internal use only. Please select the risk level of this change:

  • Low risk: Changes are fully under feature flags, or have been fully tested and validated in pre-production environments and are highly observable, or are documentation or test only.

Merge / deployment checklist

  • Confirm this change is backwards compatible with existing workflows.
  • Consider adding a changelog entry for this change.
  • Confirm the readme and docs have been updated if necessary.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
mbg added 2 commits September 18, 2025 14:13
@mbg
Refactor CQ SARIF upload in upload-sarif into a function
35454d3
@mbg
Call lstatSync on sarifPath earlier and check that the path exist…
a6161a8
…s then
@mbg
mbg requested a review from a team as a code owner September 18, 2025 13:58
@mbg
mbg requested review from Copilot and henrymercer September 18, 2025 13:58
Copilot AI reviewed Sep 18, 2025
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this 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 fixes an issue where the upload-sarif Action fails when there are no Code Scanning SARIF files, specifically for code quality-only analysis. It refactors the upload process to handle both Code Scanning and Code Quality SARIF files more gracefully and adds new outputs for tracking uploaded SARIF IDs.

  • Refactors upload logic to use a common findAndUpload function for both analysis types
  • Adds new sarif-ids output containing a JSON object with SARIF IDs for each analysis type
  • Combines upload status reports when both analysis kinds are enabled
  • Updates test configuration to test code quality-only scenarios

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
upload-sarif/action.yml Updates output descriptions and adds new sarif-ids output
src/upload-sarif-action.ts Refactors upload logic with new findAndUpload function and combined status reporting
src/upload-lib.ts Adds combineSarifUploadResults function to merge upload status reports
pr-checks/checks/upload-quality-sarif.yml Updates test to use code-quality only and validates new output
lib/upload-sarif-action.js Generated JavaScript code reflecting TypeScript changes
lib/upload-lib.js Generated JavaScript code with new export for combine function
.github/workflows/__upload-quality-sarif.yml Auto-generated workflow file updated for code-quality only testing

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread pr-checks/checks/upload-quality-sarif.yml Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread .github/workflows/__upload-quality-sarif.yml Resolved

Uh oh!

There was an error while loading. Please reload this page.

@mbg
mbg force-pushed the mbg/fix/upload-sarif-cq-only branch from 00415e9 to 79b45c8 Compare September 18, 2025 14:03
mbg
mbg commented Sep 18, 2025
View reviewed changes
Comment thread src/upload-sarif-action.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

mbg added 3 commits September 18, 2025 16:28
@mbg
Move isDirectory check into findAndUpload
c8e017d
@mbg
Handle single file case in findAndUpload
696b467
@mbg
Use findAndUpload for Code Scanning
a2ce099
@mbg
mbg force-pushed the mbg/fix/upload-sarif-cq-only branch from 6d2c7db to bca5bc4 Compare September 18, 2025 15:29
esbena
esbena reviewed Sep 19, 2025
View reviewed changes

@esbena esbena left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Can you motivate the Disable cpp in upload-quality-sarif check commit?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/upload-sarif-action.ts
await sendSuccessStatusReport(startedAt, uploadResult.statusReport, logger);
await sendSuccessStatusReport(
startedAt,
uploadResult?.statusReport || {},

@esbena esbena Sep 19, 2025

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Is it convention to add the empty object to these statuses by default?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@mbg mbg Sep 19, 2025

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Note that this was an intermediate commit and the {} just made the type checker happy until I replaced it with the statusReport from the Code Quality upload or the combination of both uploads.


The three properties of UploadStatusReport are all of type number | undefined, but the UploadStatusReport object itself is required here by sendSuccessStatusReport.

Previously, with only Code Scanning, we only would have reached sendSuccessStatusReport if the SARIF upload to Code Scanning is successful. In that case, the UploadStatusReport object always would have been populated.

Now we also have Code Quality and Code Scanning + Code Quality. So the status report should include the results of the respective upload(s).

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/upload-lib.ts Outdated
Comment on lines +1062 to +1077
for (const report of reports) {
if (report !== undefined) {
result.num_results_in_sarif = addOptional(
result.num_results_in_sarif,
report.num_results_in_sarif,
);
result.raw_upload_size_bytes = addOptional(
result.raw_upload_size_bytes,
report.raw_upload_size_bytes,
);
result.zipped_upload_size_bytes = addOptional(
result.zipped_upload_size_bytes,
report.zipped_upload_size_bytes,
);
}
}

@esbena esbena Sep 19, 2025

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

This is too ad hoc for my taste. Once we add a new numeric field to the type, it will get dropped when going through this function

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@esbena esbena Sep 19, 2025

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I.e. something like

  for (const report of reports) {
    if (!report) continue;
    for (const key of Object.keys(report) as (keyof UploadStatusReport)[]) {
      const value = report[key];
      if (typeof value !== "number") continue; // Skip non-numeric / undefined
      result[key] = ((result[key] ?? 0) as number) + value;
    }
  }

Conversely, we now risk adding things that can't be added...

Ultimately, we could do some typescript magic where we'd force ourselves to list every numerically typed property as being added or ignored, but that is complex.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@mbg mbg Sep 19, 2025

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

We could do something like that. Perhaps it is best if we leave sorting out the telemetry for a separate change so that we can think about this independently from the bug fix -- see my thoughts in the PR description and in #3123 (comment)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@mbg

mbg commented Sep 19, 2025

Copy link
Copy Markdown
Member Author

Can you motivate the Disable cpp in upload-quality-sarif check commit?

@esbena C++ has no queries in the code-quality suite and the CLI fails as a result. See https://github.com/github/codeql-action/actions/runs/17831231939/job/50696560032?pr=3123#step:5:892

esbena reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

esbena
esbena previously approved these changes Sep 19, 2025
View reviewed changes

@esbena esbena left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Perhaps it is best if we leave sorting out the telemetry for a separate change so that we can think about this independently from the bug fix

OK and conditional approve if we do that change elsewhere.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

mbg reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
mbg added 5 commits September 19, 2025 16:17
@mbg
Add new sarif-ids output to upload-sarif action
d378195
Unlike `sarif-id` which is for the single Code Scanning SARIF id, `sarif-ids` contains stringified JSON object with details of all SARIF ids.
@mbg
Fix outdated comment
7bea0e2
@mbg
Update upload-quality-sarif check to only use code-quality
e33b0ab
@mbg
Disable cpp in upload-quality-sarif check
6249793
@mbg
Fix condition
db37d92
@mbg
mbg dismissed esbena’s stale review via db37d92 September 19, 2025 15:17
@mbg
mbg force-pushed the mbg/fix/upload-sarif-cq-only branch from bca5bc4 to db37d92 Compare September 19, 2025 15:17
@mbg

mbg commented Sep 19, 2025

Copy link
Copy Markdown
Member Author

I've removed the telemetry changes, other than that in the CQ-only case we send an empty UploadStatusReport. I think that's better than setting the fields to 0 since it allows us to tell apart status reports for CS/CS+CQ that have the data for CS from those that are for CQ-only and have no data.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mbg
mbg requested a review from esbena September 19, 2025 15:22
esbena
esbena approved these changes Sep 19, 2025
View reviewed changes
@mbg
mbg merged commit 0337c4c into main Sep 19, 2025
@mbg
mbg deleted the mbg/fix/upload-sarif-cq-only branch September 19, 2025 17:48
@github-actions github-actions Bot mentioned this pull request Sep 25, 2025
Merge main into releases/v3 #3149
Merged
8 tasks
This was referenced Sep 25, 2025
Fix upload-sarif not uploading non-.sarif files #3157
Closed
Add tests for upload-sarif #3166
Merged
@coderabbitai coderabbitai Bot mentioned this pull request Apr 3, 2026
chore: integrate Detekt for static code analysis and add configuration files twangodev/jetplay#12
Merged
This was referenced Apr 12, 2026
fix(snyk): Update action and split report upload Accenture/AutoFixture.XUnit2.AutoMock#318
Merged
feat: switch code quality setup to ultracite and biome ahmadk953/poixpixel-discord-bot#769
Merged
This was referenced May 19, 2026
Add Trivy security scanning workflow (weekly + manual) ggfevans/zed-hujson#7
Merged
feat: add initial GitHub Action wrapping skill-linter aipcc-cicd/skill-linter-action#1
Merged
@coderabbitai coderabbitai Bot mentioned this pull request Aug 13, 2026
ci: scan pull requests for credentials and injection with ThreatCrush chrisleekr/binance-trading-bot#732
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

Copilot code review Copilot
Copilot review effort
Applies to this pull request for everyone.Learn more about Copilot code review.
Copilot left review comments
@esbena esbena esbena approved these changes
@henrymercer henrymercer Awaiting requested review from henrymercer

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@mbg @esbena
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.