Skip to content

ci(codeql): add actions:read so the analyze step can finish; keep private-repo gate until code scanning is available - #89

Merged
nish3451 merged 6 commits into
mainfrom
fix/codeql-analyze-upload-permission
Aug 19, 2026
Merged

ci(codeql): add actions:read so the analyze step can finish; keep private-repo gate until code scanning is available#89
nish3451 merged 6 commits into
mainfrom
fix/codeql-analyze-upload-permission

Conversation

@nish3451

@nish3451 nish3451 commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

The failure this fixes

PR #82 dropped the private-repo gate, so the CodeQL analyze job started running on every trigger — and died in its final step:

##[error]Resource not accessible by integration - https://docs.github.com/rest/actions/workflow-runs#get-a-workflow-run

The codeql-action's final status/upload call reads the workflow run (REST get-a-workflow-run), which needs the actions scope. The explicit permissions: block (contents: read + security-events: write) zeroed every other scope for GITHUB_TOKEN. Analysis itself always succeeded (141/142 JS files scanned); only the telemetry call failed.

Fix 1 — actions: read (kept, verified)

Add actions: read to the workflow-level permissions block. Proven on this PR: run 31508386840 got past the Resource not accessible error and reached the SARIF upload.

Fix 2 — the wall that cannot be fixed in a workflow file

That run then revealed the next blocker at the upload step:

##[error]Code scanning is not enabled for this repository. Please enable code scanning in the repository settings.

Confirmed by API: PATCH /repos/.../security_and_analysis[advanced_security]=enabledAdvanced security has not been purchased. (422). This repo is a private personal-account repo; GitHub code scanning for private repos requires an org with GitHub Advanced Security (Enterprise). It cannot be enabled here, so the final step can never succeed while the repo stays private.

Resolution

  • Keep the actions: read permission fix — correct and ready for the day code scanning exists.
  • Restore the private-repo gate (with the ENABLE_PRIVATE_CODEQL=1 opt-in as the enable path). Ungated, every PR/schedule run fails red and burns ~6 min of the fleet's only shared verification runner for a check that can never upload; gated, the workflow stays clean.
  • Supersedes the now-closed ci(codeql): run CodeQL on every trigger (drop private-repo gate) #82 (same gate-drop premise, which this PR corrects: the drop itself was based on the false assumption that the private repo could upload results).

Verification

  • YAML parses; permissions now actions: read / contents: read / security-events: write.
  • The analyze job's fix-to-the-upload-wall is evidenced by run 31508386840 logs (no Resource not accessible, SARIF exported, upload rejected only on code-scanning-not-enabled).
  • With the gate restored, the job skips cleanly on this PR (codeql check is not a required status; only repo-checks is required).

Summary by CodeRabbit

  • Chores
    • Improved CodeQL workflow permissions for reliable security status reporting and result uploads.
    • Added guidance documenting CodeQL availability requirements, private-repository behavior, and the opt-in configuration for private-repository analysis.

…h uploading

The analyze job now runs on every trigger (PR, push to main/codex/**,
weekly schedule, workflow_dispatch) but dies in the final step with:

  ##[error]Resource not accessible by integration
  https://docs.github.com/rest/actions/workflow-runs#get-a-workflow-run

The codeql-action's final status/upload call reads the workflow run
(REST get-a-workflow-run), which needs the actions scope. The explicit
permissions block zeroes every scope not listed, and 'actions' was not
listed, so GITHUB_TOKEN had no actions access. Add actions: read.

Also carries the private-repo gate drop (same change as PR #82) so the
fix is verifiable here: on main the gate still skips the job.

@greptile-apps greptile-apps Bot 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.

nish3451 has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The CodeQL workflow now grants actions: read permission. Comments document the existing private-repository gate, SARIF upload behavior, and ENABLE_PRIVATE_CODEQL enablement condition. The gate itself remains unchanged.

Changes

CodeQL workflow

Layer / File(s) Summary
Workflow permissions and execution
.github/workflows/codeql.yml
The workflow adds explicit actions: read permission for CodeQL operations. Comments document the existing private-repository condition, current SARIF upload failure, and ENABLE_PRIVATE_CODEQL requirement.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main changes: adding actions:read and retaining the private-repository CodeQL gate.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/codeql-analyze-upload-permission

Comment @coderabbitai help to get the list of available commands.

Run 31508386840 proved the actions:read fix: the analyze step now gets
past the telemetry call and reaches the SARIF upload, which rejects with:

  ##[error]Code scanning is not enabled for this repository.

This repo is a private personal-account repo without GitHub Advanced
Security ('Advanced security has not been purchased' from the settings
API; code scanning is an Enterprise/org-with-GHAS feature). The final
step can never succeed while the repo stays private, so running ungated
fails red on every trigger and wastes the shared VPS runner. Restore the
private-repo gate with the ENABLE_PRIVATE_CODEQL opt-in as the path to
enable the (now upload-ready) run when GHAS or public visibility lands.

@greptile-apps greptile-apps Bot 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.

nish3451 has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@nish3451 nish3451 changed the title ci(codeql): add actions:read so the analyze step can finish uploading ci(codeql): add actions:read so the analyze step can finish; keep private-repo gate until code scanning is available Aug 11, 2026

@greptile-apps greptile-apps Bot 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.

nish3451 has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.

…+ private-repo gate)

main removed .github/workflows/codeql.yml (PR #122, no GHAS entitlement).
This PR re-adds it with the actions:read permission fix and the restored
private-repo gate (ENABLE_PRIVATE_CODEQL opt-in), so the job stays clean
(gated) until code scanning/GHAS is provisioned. Resolve modify/delete in
favor of the PR version.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@greptile-apps greptile-apps Bot 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.

Your trial has ended. Reactivate Greptile to resume code reviews.

@greptile-apps greptile-apps Bot 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.

Your trial has ended. Reactivate Greptile to resume code reviews.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@greptile-apps greptile-apps Bot 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.

Your trial has ended. Reactivate Greptile to resume code reviews.

@nish3451
nish3451 merged commit a9c9543 into main Aug 19, 2026
3 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.

1 participant