Repository navigation
fix(github): trust a bot on its own commit in the repository - #35
Conversation
GitHub reports permission none for a GitHub App's bot account whatever access the App has, so Renovate and other App PRs were never approved even with a clean Tier S review, and stayed blocked on protected branches. A branch in the repository itself can only be pushed with write access, so that is the proof for a bot. Fork PRs from bots stay untrusted.
A same-repository branch only proves that someone with write access pushed it. An App with pull_requests write could open a PR on another author's branch, so the head commit must be the bot's own too.
🟢 Tier S · Ready to merge
This pull request allows a GitHub App bot to count as trusted when its pull request targets a branch in the same repository and the head commit is attributed to that bot; otherwise the existing association and permission checks remain in place. It carries the pull-request and commit metadata through the GitHub client and approval guard, and adds coverage for same-repository versus fork detection, commit attribution, and lookup failures. Latest changes: The latest commit adds tests for bot branch classification and for trusted-author decisions covering matching, mismatched, missing, and unreadable commit authors, plus fork handling.
📂 Walkthrough · 7
✅ Fixed since the last review · 1
Reviewed the commits since |
The rule decides what Hansi may approve, so pin its cases: the bot's own head commit, someone else's or an unattributed commit, an unreadable commit, and a fork. The engine fake no longer shortcuts bots, since it never checked the head.
Why
Hansi never approves a pull request opened by a GitHub App bot, however clean the review is.
isTrustedAuthorfalls back to the collaborator permission API, and GitHub answersnonefor an App's bot account whatever access the App has, so the summary says the bot "does not have write access to this repository".On Appwrite's repositories that leaves Renovate pull requests at Tier S with only a comment. On branches that require a review (for example appwrite-labs/monitoring#704) they stay blocked, 23 of them at the moment.
Fix
A bot is trusted when its pull request's branch is in the repository itself and the head commit on it is the bot's own, because only write access can put that commit there. An App that can only open pull requests can't pass this on someone else's branch. No configuration is needed, and it works per repository for every installation.
approveOutsideContributorswasn't an option: it would also approve human forks.What stays the same
Worth weighing
This also covers Dependabot and any other App bot with a branch in the repository. A dependency bot's body quotes upstream release notes, so that text can now reach a review that may approve. It was already treated as untrusted input, and the approval guards outside the model still apply.
Testing
bun run check,bun run lintandbun test packages/github apps/workerpass. Against the real API,isTrustedAuthorreturns true for the Renovate pull requests appwrite-labs/monitoring#704 and open-runtimes/open-runtimes#592. appwrite/cdn-for-astro#20 (a person's fork) givesbotOnOwnBranch=false.Here
bun run check,bun run lintandbun run testall pass.