Skip to content

fix(codeql): skip on merge_group like scorecard and zizmor already do - #340

Merged
CybotTM merged 2 commits into
mainfrom
fix/codeql-skip-merge-group
Aug 2, 2026
Merged

fix(codeql): skip on merge_group like scorecard and zizmor already do#340
CybotTM merged 2 commits into
mainfrom
fix/codeql-skip-merge-group

Conversation

@CybotTM

@CybotTM CybotTM commented Aug 2, 2026

Copy link
Copy Markdown
Member

GitHub deletes the gh-readonly-queue ref the moment a merge queue finishes, which races the SARIF upload inside codeql-action/analyze. scorecard.yml already guards against this and its comment calls the result "a guaranteed ref ... not found failure"; zizmor.yml skips its whole job for the same reason. codeql.yml never got the guard.

The consequence is not a cosmetic red check: the queue run fails, and github-merge-queue[bot] ejects the pull request from the queue. It happened on netresearch/ofelia#783, a pull request that deletes one YAML file and touches no Go code at all — added to the queue at 18:40:42, removed at 18:46:13, with codeql / Analyze (go) reporting ref 'refs/heads/gh-readonly-queue/main/pr-783-...' not found in this repository. Every merge-queue repository that calls this reusable is exposed to the same race.

No analysis coverage is lost. The pull-request head is analysed before it ever reaches the queue, and the push and schedule events that keep the default-branch results current run against stable refs — which is exactly the reasoning already written down in scorecard.yml.

GitHub deletes the gh-readonly-queue ref the moment the queue finishes, which
races the SARIF upload inside codeql-action/analyze. scorecard.yml calls that
"a guaranteed `ref ... not found` failure" and skips the upload on merge_group;
zizmor.yml skips its whole job for the same reason. codeql.yml never got the
guard, so every merge-queue repository calling it can have a healthy pull
request ejected from the queue by an infrastructure race.

Seen on netresearch/ofelia#783, a one-file deletion: the queue run failed with
`ref 'refs/heads/gh-readonly-queue/main/pr-783-...' not found in this
repository` and github-merge-queue[bot] removed the pull request six minutes
after adding it.

The pull-request head is analysed before it ever reaches the queue, and push
and schedule events run against stable refs, so no coverage is lost.

Signed-off-by: Sebastian Mendel <github@sebastianmendel.de>
Copilot AI review requested due to automatic review settings August 2, 2026 19:18

Copilot AI 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.

Pull request overview

Note

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Skip CodeQL jobs during merge-queue (merge_group) runs to avoid a known race where GitHub deletes the gh-readonly-queue ref before codeql-action/analyze uploads SARIF, which can fail the run and eject PRs from the merge queue.

Changes:

  • Add a job-level if guard to skip the prepare job on merge_group.
  • Add a job-level if guard to skip the analyze job on merge_group.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/workflows/codeql.yml Outdated
Comment thread .github/workflows/codeql.yml Outdated
Comment thread .github/workflows/codeql.yml Outdated
Skipping both jobs would have made the check report `skipped` for every
merge-queue run. A queue that requires `codeql / Analyze (...)` then never gets
a verdict and waits until it times the pull request out — trading one ejection
cause for another, worse one.

The analysis now still runs in the queue; only the upload is turned off, which
is the part that touches the gh-readonly-queue ref GitHub deletes when the
queue finishes. `upload: never` is the documented value for exactly that. The
pull-request head is analysed before it reaches the queue, and push and
schedule events run against stable refs, so no result is lost.

Signed-off-by: Sebastian Mendel <github@sebastianmendel.de>
@CybotTM
CybotTM requested a review from Copilot August 2, 2026 19:47
@sonarqubecloud

sonarqubecloud Bot commented Aug 2, 2026

Copy link
Copy Markdown

Copilot AI 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.

Pull request overview

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

@CybotTM
CybotTM merged commit a7a045c into main Aug 2, 2026
13 checks passed
@CybotTM
CybotTM deleted the fix/codeql-skip-merge-group branch August 2, 2026 19:56
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