Skip to content

fix(go-check): skip gosec SARIF upload on merge_group events#116

Merged
CybotTM merged 1 commit into
mainfrom
fix/gosec-skip-merge-group
May 9, 2026
Merged

fix(go-check): skip gosec SARIF upload on merge_group events#116
CybotTM merged 1 commit into
mainfrom
fix/gosec-skip-merge-group

Conversation

@CybotTM
Copy link
Copy Markdown
Member

@CybotTM CybotTM commented May 9, 2026

Summary

The codeql-action/upload-sarif step in the gosec job fails on every merge_group run because GitHub deletes the gh-readonly-queue/<branch>/pr-NNN-<sha> ref the moment the merge completes. By the time upload-sarif tries to attach results to that ref, it's gone:

##[error]ref 'refs/heads/gh-readonly-queue/main/pr-NNN-...' not found in this repository

This produces a guaranteed failure on every successful merge, which silently bypasses CI gating wherever branch protection treats merge_group results as non-required (e.g. netresearch/ofelia, where it allowed broken commits to land on main).

The push and pull_request events run the same scan against stable refs, so security coverage is not lost — only the redundant (and impossible) merge_group upload is skipped. Mirrors the existing job-level exclusion in gitleaks.yml.

Observed failures across recent merge_group runs in netresearch/ofelia:

Test plan

  • Once merged, verify a fresh ofelia merge_group run no longer fails on Upload gosec SARIF
  • Verify gosec SARIF still uploads from push/pull_request events (Security tab → Code scanning → gosec category)

The codeql-action/upload-sarif step fails 100% of the time on
merge_group runs because GitHub deletes the gh-readonly-queue
ref the moment the merge completes. By the time upload-sarif
tries to attach results to that ref, it is gone:

  ##[error]ref 'refs/heads/gh-readonly-queue/main/pr-NNN-...'
  not found in this repository

This produces a guaranteed failure on every successful merge,
which silently bypasses CI gating wherever branch protection
treats merge_group results as non-required.

Push and pull_request events run the same scan against a stable
ref, so security coverage is not lost; only the redundant
merge_group upload is skipped. Mirrors the existing exclusion
in gitleaks.yml.

Signed-off-by: Sebastian Mendel <info@sebastianmendel.de>
Copilot AI review requested due to automatic review settings May 9, 2026 18:28
@gemini-code-assist
Copy link
Copy Markdown

Note

Gemini is unable to generate a review for this pull request due to the file types involved not being currently supported.

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 9, 2026

Copy link
Copy Markdown

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 the reusable Go check workflow’s gosec job from failing on merge_group runs by skipping the SARIF upload step when the triggering event is merge_group, avoiding a race where the ephemeral gh-readonly-queue/... ref is deleted before upload-sarif can attach results.

Changes:

  • Add an explanatory comment documenting the merge_group ref deletion race with codeql-action/upload-sarif.
  • Gate the “Upload gosec SARIF” step to run only when github.event_name != 'merge_group' while preserving uploads for push and pull_request events.

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

@CybotTM CybotTM merged commit 995fe72 into main May 9, 2026
13 checks passed
@CybotTM CybotTM deleted the fix/gosec-skip-merge-group branch May 9, 2026 18:45
CybotTM added a commit that referenced this pull request May 10, 2026
## Summary

Completes the same fix as #116 (gosec) for the three remaining reusable
workflows that upload SARIF without a merge_group guard:
\`build-container.yml\`, \`release-go-app.yml\`, \`scorecard.yml\`. The
job-level guard already exists in \`gitleaks.yml\`.

When a workflow with a SARIF upload step is triggered by
\`merge_group\`, \`codeql-action/upload-sarif\` fails 100% of the time
because GitHub deletes the \`gh-readonly-queue/<branch>/pr-NNN-<sha>\`
ref the moment the merge completes:

\`\`\`
##[error]ref 'refs/heads/gh-readonly-queue/...' not found in this
repository
\`\`\`

Push, schedule, and release events run with stable refs, so security
coverage is unchanged — only the impossible merge_group upload is
skipped.

## Audit context

5 reusable workflows in this repo upload SARIF (\`grep -l upload-sarif
.github/workflows/\`):

| Workflow | Status |
|---|---|
| \`gitleaks.yml\` | Already had job-level merge_group guard ✓ |
| \`go-check.yml\` (gosec step) | Fixed in #116 ✓ |
| \`build-container.yml\` | **Fixed here** |
| \`release-go-app.yml\` | **Fixed here** |
| \`scorecard.yml\` | **Fixed here** |

## Test plan

- [ ] Verify scorecard SARIF still uploads on push/schedule events
(Security tab → Code scanning → scorecard)
- [ ] Verify trivy SARIF still uploads on release events
(release-go-app.yml, build-container.yml)
- [ ] No callers regress on merge_group runs
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