Repository navigation
ci: give the auto-labeler permission to label pull requests - #398
Conversation
The workflow added in #383 has never succeeded on a pull request. All three pull_request_target runs so far failed with: POST /repos/adamgell/cmtraceopen/issues/<n>/labels 403 Resource not accessible by integration The script computes the labels correctly — the failing run for #397 had body '{"labels":["enhancement","intune","parser","device","feature"]}' — and then cannot write them. Cause: labelling a pull request requires `pull-requests: write`, even though the REST path is under /issues. The workflow declared only `issues: write`, and because an explicit `permissions:` block replaces the repository default rather than adding to it, and this repo's default_workflow_permissions is `read`, the token had no pull-request scope at all. The issues: opened trigger was unaffected. Adding `pull-requests: write` is the minimum needed; issue labelling keeps working through the existing `issues: write`. Verified: `gh run list --workflow=label-new-items.yml` shows failure on all three pull_request_target runs to date (#397, and the two before it), and `gh api repos/:owner/:repo/actions/permissions/workflow` reports default_workflow_permissions=read. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
Warning Review limit reached
Next review available in: 1 minute Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Comment |
There was a problem hiding this comment.
Pull request overview
Fixes the GitHub Actions auto-labeling workflow so it can successfully apply labels to pull requests triggered via pull_request_target, aligning the workflow token permissions with GitHub’s requirement that PR labeling needs pull-requests: write even when using the /issues/{n}/labels REST endpoint.
Changes:
- Adds
pull-requests: writeto the workflowpermissions:block (keeping existingissues: write). - Documents why the additional permission is required and why the explicit
permissions:block must include it (repo defaults are read-only).
The auto-labeler added in #383 has never successfully labelled a pull request. All three
pull_request_targetruns to date failed:The script itself works — the failing run for #397 got as far as
{"labels":["enhancement","intune","parser","device","feature"]}and then could not write them.Cause. Labelling a pull request requires
pull-requests: write, even though the REST path lives under/issues. The workflow declared onlyissues: write. An explicitpermissions:block replaces the repository default rather than adding to it, and this repo hasdefault_workflow_permissions: read, so the token ended up with no pull-request scope at all. Theissues: openedtrigger was unaffected, which is why the gap was not obvious.Fix. Add
pull-requests: write. That is the minimum needed; issue labelling keeps working through the existingissues: write.Evidence:
This PR is itself the test: if it labels correctly on open, the fix is confirmed — though note it will run with the base branch workflow, so the real confirmation is the next PR opened after this merges.