Skip to content

ci: require an approving review for non-self-authored PRs - #241

Closed
getappz wants to merge 1 commit into
masterfrom
ci/require-review-for-non-self-prs
Closed

ci: require an approving review for non-self-authored PRs#241
getappz wants to merge 1 commit into
masterfrom
ci/require-review-for-non-self-prs

Conversation

@getappz

@getappz getappz commented Jul 18, 2026

Copy link
Copy Markdown
Owner

Summary

  • New .github/workflows/require-review-for-others.yml: a required-status-check that auto-passes for trusted PR authors (TRUSTED_PR_AUTHORS, default getappz) and requires an actual approving review (checked via the Reviews API, independent of branch-protection review-count settings) for everyone else
  • Why not native branch protection: "Require review from Code Owners" applies uniformly to every PR regardless of author, which deadlocks — @getappz can never approve @getappz's own PR (GitHub blocks self-approval at the platform level, confirmed this session on chore: add CODEOWNERS #239/ci: auto-enable merge-when-ready on every PR open #240). Rulesets' bypass lists are actor-based (whoever performs the merge bypasses), not author-based, so a bypass for @getappz would let them merge anyone's PR without review, including external ones — the opposite of the goal
  • Concrete motivating case: PR Block webhook SSRF via hostnames that resolve to internal IPs #230, a security fix (webhook SSRF) opened by app/devin-ai-integration directly against this repo (not a fork — Devin has write access). Once this check is required, Devin's PRs (and any future external contributor's) need your explicit approval; your own PRs keep auto-merging freely
  • Configurable without a code change: gh variable set TRUSTED_PR_AUTHORS --body "getappz,other-login" to add more trusted authors (e.g. once an agentflare-bot identity exists)

Follow-up needed after merge

This workflow only becomes enforced once its check name ("Require review (non-self authors)") is added to branch protection's required status checks — I'll do that once this lands and the check has run at least once so GitHub knows its exact name.

Test plan

  • Simulated the trusted-author matching logic locally against getappz/devin-ai-integration/multi-entry-list cases — matches only exact logins in the comma-list, falls through to "needs review" for anything else (fail-secure regardless of a bot's exact login string format)

Summary by CodeRabbit

  • Chores
    • Added automated pull request review enforcement.
    • Trusted authors can bypass the approval requirement.
    • Other pull requests must receive at least one approving review before passing the status check.

No native branch-protection/ruleset feature does this -- bypass lists
are actor-based (whoever merges bypasses), not author-based, so a
bypass for getappz would let getappz merge ANYONE's PR without review,
not just their own. Reimplemented as a required status check instead:
trusted authors (TRUSTED_PR_AUTHORS, default getappz) skip the
requirement (avoids the self-approval deadlock GitHub enforces
platform-wide), everyone else -- Devin, any future external
contributor -- needs an actual approving review before merge.
@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a GitHub Actions workflow that runs on pull request and review events, allows configured trusted authors to bypass approval, and fails for other authors until an approving review exists.

Changes

Review Enforcement

Layer / File(s) Summary
Approval requirement workflow
.github/workflows/require-review-for-others.yml
Adds a status-check job that reads TRUSTED_PR_AUTHORS, bypasses trusted authors, queries pull request reviews through the GitHub CLI, and passes when an APPROVED review is present.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: requiring approving reviews for non-trusted PR authors.
Description check ✅ Passed The description covers the summary, test plan, and reviewer notes, though the template's risk and compatibility details are only implicit.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ci/require-review-for-non-self-prs

Comment @coderabbitai help to get the list of available commands.

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/require-review-for-others.yml:
- Around line 46-48: Update the approval check in the workflow’s gh api
invocation to paginate all pull-request reviews, restrict approvals to reviews
targeting the current head commit, and evaluate each reviewer’s most recent
review state so stale approvals cannot satisfy the requirement. Preserve the
existing conditional that proceeds only when at least one current approving
reviewer remains.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 37eb4332-a531-4c2e-be8f-145b03152072

📥 Commits

Reviewing files that changed from the base of the PR and between ef1338a and 233c21c.

📒 Files selected for processing (1)
  • .github/workflows/require-review-for-others.yml

Comment on lines +46 to +48
approvals=$(gh api "repos/${{ github.repository }}/pulls/$PR_NUMBER/reviews" \
--jq '[.[] | select(.state=="APPROVED")] | length')
if [ "$approvals" -gt 0 ]; then

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

git ls-files .github/workflows/require-review-for-others.yml
echo "----"
wc -l .github/workflows/require-review-for-others.yml
echo "----"
cat -n .github/workflows/require-review-for-others.yml | sed -n '1,140p'

Repository: getappz/agentflare

Length of output: 2610


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the workflow logic and any local usage of the Reviews API or review state handling.
rg -n "pulls/.*/reviews|APPROVED|submitted_at|commit_id|head.sha|per_page=100|gh api --paginate" .github/workflows -S

Repository: getappz/agentflare

Length of output: 411


Require a current approving review, not any historical one. .github/workflows/require-review-for-others.yml:46-48 counts every APPROVED review object, so an older approval can still pass after new commits, and this call only reads the first reviews page. Filter to the current head.sha, paginate, and evaluate each reviewer’s latest state.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/require-review-for-others.yml around lines 46 - 48, Update
the approval check in the workflow’s gh api invocation to paginate all
pull-request reviews, restrict approvals to reviews targeting the current head
commit, and evaluate each reviewer’s most recent review state so stale approvals
cannot satisfy the requirement. Preserve the existing conditional that proceeds
only when at least one current approving reviewer remains.

@getappz

getappz commented Jul 18, 2026

Copy link
Copy Markdown
Owner Author

Simplifying: folding this into auto-merge.yml's existing author check instead of a separate required-status-check (which has a self-modifying exploit gap under pull_request triggers) — see auto-merge.yml. Popular repos don't enforce required-review-count for solo maintainers; they just don't auto-merge non-self PRs and review those by hand.

@getappz getappz closed this Jul 18, 2026
@getappz
getappz deleted the ci/require-review-for-non-self-prs branch July 18, 2026 04:58
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