fix(github): skip assertPermissions when use_github_token is true#17225
Open
wewelll wants to merge 1 commit intoanomalyco:devfrom
Open
fix(github): skip assertPermissions when use_github_token is true#17225wewelll wants to merge 1 commit intoanomalyco:devfrom
wewelll wants to merge 1 commit intoanomalyco:devfrom
Conversation
GitHub App bot actors (e.g. my-bot[bot]) return permission: none from the collaborators API because Apps authenticate via installation tokens, not as traditional collaborators. When use_github_token is true, the caller is providing their own GITHUB_TOKEN and managing authentication directly, making the collaborator-level permission check both unnecessary and broken for bot actors. Closes anomalyco#17224
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
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.
Issue for this PR
Closes #17224
Type of change
What does this PR do?
When
opencode github runis triggered by apull_requestevent where the actor is a GitHub App bot (e.g.my-bot[bot]), theassertPermissions()check fails because the GitHub collaborator permissions API always returnspermission: nonefor App bot accounts. Apps authenticate via installation tokens, not as traditional collaborators.When
use_github_token: true, the caller is explicitly providing their ownGITHUB_TOKENand managing authentication. The collaborator-level permission check is both unnecessary and broken for bot actors in this mode.The fix wraps
assertPermissions()inif (!useGithubToken)so the check is skipped when the caller provides their own token:if (isUserEvent) { - await assertPermissions() + if (!useGithubToken) { + await assertPermissions() + } await addReaction(commentType) }How did you verify your code works?
spiko-bot[bot]triggers apull_requestevent withuse_github_token: trueand getspermission: nonefrom the collaborators APIpermission: nonefor all GitHub App bot accounts (documented platform behavior)e2e (windows)failure is pre-existing on thedevbranch (same Playwright flake), unrelated to this changeChecklist