Skip to content

cloudflare-worker: fallback to collaborator permissions check - #70

Open
BKPepe wants to merge 1 commit into
mainfrom
feature/verify-contributor-maintainer-permission
Open

cloudflare-worker: fallback to collaborator permissions check#70
BKPepe wants to merge 1 commit into
mainfrom
feature/verify-contributor-maintainer-permission

Conversation

@BKPepe

@BKPepe BKPepe commented Jul 24, 2026

Copy link
Copy Markdown
Member

GitHub API returns author_association: CONTRIBUTOR (or NONE) for users whose organization membership is set to private, even if they are repository maintainers with full write/commit access.

When an override command ([allow branch] or [allow cherry-pick]) or PR action is processed and the author's author_association is not OWNER, MEMBER, or COLLABORATOR, fall back to checking GET /repos/{owner}/{repo}/collaborators/{username}/permission.

If the response indicates admin, write, or maintain permission on the repository, treat the user as a maintainer (isMaintainer = true). Results are cached per request invocation to avoid unnecessary API subrequests.

GitHub reports author_association CONTRIBUTOR (or NONE) for users whose
organization membership is private, even when they are maintainers with
write access. Those maintainers cannot use the [allow branch] and
[allow cherry-pick] overrides, and their comments do not trigger a
recheck.

Where the association is not enough, ask the repository permission API
(/collaborators/{username}/permission) and accept admin, write or
maintain.

Every answer costs a subrequest, so one resolver memoizes them for the
whole request. Bots and comments without an override command are never
resolved, comments from everyone else are dropped before the pull
request is fetched, and the PR author is resolved only where a bypass
can apply. Lookups stop once the reserved subrequest headroom is
reached. A 404 means the user is not a collaborator, so it is no longer
logged as an API failure.

Signed-off-by: Josef Schlehofer <pepe.schlehofer@gmail.com>
@BKPepe
BKPepe force-pushed the feature/verify-contributor-maintainer-permission branch from db11546 to 3928240 Compare July 26, 2026 07:14
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