Fix approval gate treating org members as external contributors#11435
Fix approval gate treating org members as external contributors#11435
Conversation
Replace unreliable author_association check with org membership API
call. Webhook payloads compute author_association in an unauthenticated
context, which returns CONTRIBUTOR instead of MEMBER for org members
with private membership visibility.
The new approach uses a check-trust job that:
1. Fast-paths same-repo PRs as trusted (write access required to push)
2. For fork PRs, calls GET /orgs/{org}/members/{username} to verify
org membership regardless of visibility settings
3. Falls back to requiring approval for unrecognized users
There was a problem hiding this comment.
Pull request overview
Updates the cloud functional test GitHub Actions workflow to replace author_association-based trust checks with an explicit “check trust” job that determines whether a pull_request_target PR author is external (fork + non-org-member), and gates execution behind an environment approval when needed.
Changes:
- Add a
check-trustjob that classifies fork PRs as external by querying GitHub org membership. - Update
approval-gateto depend oncheck-trustoutput rather thanauthor_association. - Adjust
setupjob dependencies/conditions to incorporate the new trust-check flow.
| outputs: | ||
| is-external: ${{ steps.check.outputs.is-external }} | ||
| permissions: {} | ||
| steps: |
| (github.event_name != 'pull_request_target' || needs.approval-gate.result == 'success' || needs.approval-gate.result == 'skipped') && | ||
| !cancelled() && | ||
| needs.check-trust.result != 'failure' && | ||
| needs.approval-gate.result != 'failure' && |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #11435 +/- ##
==========================================
- Coverage 51.24% 51.22% -0.02%
==========================================
Files 699 699
Lines 44062 44062
==========================================
- Hits 22580 22572 -8
- Misses 19326 19330 +4
- Partials 2156 2160 +4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Signed-off-by: Sylvain Niles <[email protected]>
|
|
||
| # Fork PR: check if the author is an org member via GitHub API. | ||
| # GET /orgs/{org}/members/{username} returns 204 for members, 404/302 otherwise. | ||
| HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" \ |
There was a problem hiding this comment.
suggestion: you can use native GH CLI here, with filtering flags like --query. It will simplify the whole script a lot.
Description
The approval gate in
functional-test-cloud.yamlincorrectly treats org members as external contributors, requiring manual approval for every PR — even from org owners.Root Cause
The workflow uses
github.event.pull_request.author_associationto determine trust. However, GitHub webhook payloads computeauthor_associationin an unauthenticated context. For org members with private membership visibility, this returnsCONTRIBUTORinstead ofMEMBER, causing the approval gate to trigger.Evidence from workflow logs:
author_association: MEMBER→ gate skipped ✅author_association: MEMBER→ gate skipped ✅author_association: CONTRIBUTOR→ gate triggered ❌author_association: CONTRIBUTOR→ gate triggered ❌author_association: CONTRIBUTOR→ gate triggered ❌Fix
Replace the
author_associationcheck with a newcheck-trustjob that reliably determines trust:GET /orgs/{org}/members/{username}API call (works regardless of membership visibility).external-contributor-approvalenvironment.This also correctly handles org members who prefer to work from forks.
Type of change
Contributor checklist
Please verify that the PR meets the following requirements, where applicable: