fix(pr-size): mint bot token with pull-requests:write and degrade on runtime 403 (BE-4385)#68
Open
mattmillerai wants to merge 2 commits into
Open
fix(pr-size): mint bot token with pull-requests:write and degrade on runtime 403 (BE-4385)#68mattmillerai wants to merge 2 commits into
mattmillerai wants to merge 2 commits into
Conversation
…runtime 403 (BE-4385) The comment job's sticky-comment upsert 403s on every PR because the app token is minted with only issues:write, but the issue-comments endpoints on a pull request require the app's Pull requests permission (GitHub's shared issues/PR endpoint model). Mint with pull-requests:write instead, and harden the upsert step (continue-on-error + id) so a runtime permission failure degrades to status + step summary rather than reddening the check.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe PR-size workflow now mints tokens with pull request write permission and treats sticky comment upsert failures as degraded mode, with messaging that identifies missing installation permissions as a possible cause. ChangesPull request comment flow
Possibly related PRs
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify code
Comment |
mattmillerai
marked this pull request as ready for review
July 24, 2026 17:45
There was a problem hiding this comment.
🔍 Cursor Review — Consolidated panel
Triggered by @mattmillerai.
Found 1 finding(s).
| Severity | Count |
|---|---|
| 🟢 Low | 1 |
Panel: 8/8 reviewers contributed findings.
…-4385) The Note degraded mode post-failed branch hard-coded a single cause (the bot app lacks Pull requests permission), but this PR's mint now requests pull-requests:write, making that 403 the least-likely cause; continue-on- error also swallows network/5xx, rate-limit, and malformed-body failures. Point operators at the Upsert step log for the real error instead of asserting a permissions cause. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
wei-hai
approved these changes
Jul 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
ELI-5
When a pull request is too big, a bot leaves a comment saying so. To leave that comment the bot needs a key with the right permission. We were minting the key with the "Issues" permission, but a comment on a pull request actually needs the "Pull requests" permission — GitHub treats PR comments through the same endpoint as issue comments, and for GitHub Apps that endpoint checks the Pull requests scope. So the comment 403'd on every PR. This swaps the requested scope to
pull-requests: write, and also makes the comment step fail-soft: if posting still can't happen (e.g. the app isn't granted the permission yet on that install), the check stays green and the full size report still shows up in the job's step summary instead of turning the check red.What changed
.github/workflows/pr-size.yml, thecommentjob:permission-pull-requests: writeinstead ofpermission-issues: write. The issue-comments API on a pull request checks the app's Pull requests permission for GitHub Apps, so that is the one scope required (read is implied for the list-comments GET).issues:writewas both wrong (didn't grant PR-comment access) and, if kept alongside, an ungranted extra that 422s the mint — this workflow only ever comments on pull requests.continue-on-error: trueandid: upsert. Design intent already stated in the file is that the comment path "must degrade to status + summary, never get a red check"; today only the mint step was guarded, so a runtime 403 (proven live on Jul-24 after an Issues grant) escaped it and reddened the check. "Note degraded mode" now also fires onsteps.upsert.outcome == 'failure'with a message pointing at the likely missing Pull requests permission and the step-summary report.Why it's safe / notable
continue-on-erroron the mint step) and degrades to a green check with no comment — i.e. the pre-2026-07-24 behavior that unblocks merges. Once the grant lands, comments post correctly.steps.upsert.outcome == 'failure'in the degraded-mode gate. This relies on GitHub Actions semantics:outcomereflects the step result beforecontinue-on-erroris applied (which only rewritesconclusiontosuccess), so a tolerated 403 still reads asoutcome == 'failure'. This mirrors the existingsteps.bot.outcome == 'success'guard on the already-tolerated mint step. When the upsert step is skipped (bot mint didn't succeed), its outcome isskipped, notfailure, so that path correctly falls through to the existing creds-absent/mint-failed message.uses:were added, so all actions stay SHA-pinned (zizmor clean).actionlintpasses (it runs shellcheck over the embedded run scripts).test-pr-size.ymlandscripts/check-pr-size/contain no assertions on the mint permissions or the comment-job step layout (they cover the Go counting logic only), so nothing to update.groom.yml'spermission-issuesuses are unrelated — groom files GitHub issues, not PR comments — and were left untouched.Verification
actionlint .github/workflows/pr-size.yml→ clean.bump-pr-size-callers.ymlpath filter includes.github/workflows/pr-size.yml, so the merge should fire the caller-bump run and open the SHA-bump PR in the caller repo (the delivery vehicle, tracked by the sibling cloud ticket).This is not a capability-denial change (it adds tolerance and degrades gracefully), so the negative-claim falsification discipline does not apply.