Skip to content

fix(github): Ask to merge only a requester with write access - #4472

Merged
BYK merged 3 commits into
mainfrom
fix/github-merge-ask-viewer-permission
Nov 26, 2026
Merged

BYK merged 3 commits into
mainfrom
fix/github-merge-ask-viewer-permission

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

The next-action sync gave the requester a "Ready to merge" item based only on PR state: open, not a draft, auto-merge off, mergeStateStatus CLEAN, no pending review, no change request. It never checked whether the requester can merge on the repo. Two cases hit @BYK, whose role is read on both repos. Neither repo requires a review, so GitHub reports CLEAN:

  • getsentry/shepherd#30: @BYK had approved it, so the item said that it is approved and can merge.
  • getsentry/herald#8: nobody had reviewed it, so the item said to review it, then merge it.

Now nextAction takes a mergeAccess input for the requester, and a requester without it gets no merge ask:

  • Before an approval, the PR is in limbo, so Junior asks the requester to review it on GitHub and they get "Review requested". After they approve, the item closes. A person with write access merges it.
  • An open merge item closes on the next sync with "Only a person with write access can merge it." When the requester has not reviewed yet, as on herald#8, the same sync asks for their review, and the item becomes "Review requested".
  • Junior knows a requester's access only through their linked GitHub login. With no linked login, there is no merge ask.

The access comes from GET /repos/{owner}/{repo}/collaborators/{login}/permission. It is read with a metadata-only installation token and kept in the plugin cache for 10 minutes. This is the read that loadRepositoryRole already does. Both now share one cache entry that holds GitHub's base permission (admin, write, read, or none) and role_name. Write and admin can merge, and maintain and custom roles map to one of them. I did not use the requester's own token because the sync runs from webhooks and tasks that have none. The endpoint answers for the login, so the App token is enough. A sync reads the access only when the action would be merge or the saved action is merge, so most recomputes read nothing. Nothing is written to tables.

The Inbox label comes from the item title, so the dashboard needs no change. design/github.md now states the write-access rule, in the text that @BYK confirmed.

For #4395: the generated github:pull_request table needs a new requester input, mergeAccess. It gates the merge rows in the same way as canMerge in pull-request-next-action.ts. The sync gets it from the cached permission read above.

via @BYK.

--

View Session [Sentry]

@vercel

vercel Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
junior-docs Ready Ready Preview Nov 26, 2026 11:38am UTC

Request Review

@sentry-junior
sentry-junior Bot marked this pull request as ready for review November 26, 2026 11:49
@sentry-junior
sentry-junior Bot requested a review from BYK November 26, 2026 11:49
@github-actions github-actions Bot added the risk: high PR risk score: high label Nov 26, 2026

@cursor cursor 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.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 399f6a9. Configure here.

@BYK
BYK merged commit efdfd40 into main Nov 26, 2026
58 checks passed
@BYK
BYK deleted the fix/github-merge-ask-viewer-permission branch November 26, 2026 11:56
BYK pushed a commit that referenced this pull request Nov 26, 2026
…rule (#4476)

#4472 gives no merge ask to a requester without write
access, but only a webhook sync applies the rule. A quiet pull request
whose "Ready to merge" item went to such a requester, like
getsentry/shepherd#30, keeps the item until its next GitHub event, which
can be never.

The one-off backfill re-derives the next action of every open Junior
pull request, and `pull-request-action-backfill.ts` says to bump
`VERSION` when a new rule must reach quiet pull requests. This bumps it
to `v2`, so the heartbeat runs the backfill once more. The sync changes
an item only when the derived action is not the saved one, so most pull
requests keep their items. A stale merge item closes. Where the
requester has not reviewed yet, it becomes a review ask.

v1 also asked in limbo where the requester had acted before the last
push, to bring limbo asks to quiet pull requests. v2 only brings the
merge access rule, so `ASK_AFTER_REQUESTER_ACTED` is off and it asks in
limbo as a webhook does. A requester who already reviewed or commented
gets no new GitHub review request.

Cursor Bugbot found the missing rerun on #4472 after it
merged.

<!-- junior-request-attribution:start -->
via @BYK.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:local%3Aweb%3Aa0d5d9396e47d3c04ab85406 -->

--

[View
Session](https://junior-prod.sentry.dev/conversations/local%3Aweb%3Aa0d5d9396e47d3c04ab85406)
[[Sentry]](https://sentry.sentry.io/explore/conversations/local%3Aweb%3Aa0d5d9396e47d3c04ab85406/?project=4510944073809921)

<!-- junior-session-footer:end -->

---------

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>

This branch was successfully deployed

1 active deployment
Preview – junior-docs — 399f6a91 Deployed Nov 26, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: high PR risk score: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant