Skip to content

fix(github): skip assertPermissions when use_github_token is true#17225

Open
wewelll wants to merge 1 commit intoanomalyco:devfrom
wewelll:fix/skip-permissions-check-with-github-token
Open

fix(github): skip assertPermissions when use_github_token is true#17225
wewelll wants to merge 1 commit intoanomalyco:devfrom
wewelll:fix/skip-permissions-check-with-github-token

Conversation

@wewelll
Copy link

@wewelll wewelll commented Mar 12, 2026

Issue for this PR

Closes #17224

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

When opencode github run is triggered by a pull_request event where the actor is a GitHub App bot (e.g. my-bot[bot]), the assertPermissions() check fails because the GitHub collaborator permissions API always returns permission: none for App bot accounts. Apps authenticate via installation tokens, not as traditional collaborators.

When use_github_token: true, the caller is explicitly providing their own GITHUB_TOKEN and managing authentication. The collaborator-level permission check is both unnecessary and broken for bot actors in this mode.

The fix wraps assertPermissions() in if (!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?

  • Verified the failing CI run where spiko-bot[bot] triggers a pull_request event with use_github_token: true and gets permission: none from the collaborators API
  • Confirmed the GitHub collaborators API returns permission: none for all GitHub App bot accounts (documented platform behavior)
  • The e2e (windows) failure is pre-existing on the dev branch (same Playwright flake), unrelated to this change

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

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
@github-actions github-actions bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. labels Mar 12, 2026
@github-actions
Copy link
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

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.

github run: assertPermissions() fails for GitHub App bot actors even with use_github_token: true

1 participant