Fix approval gate treating org members as external contributors#11435
Open
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
Contributor
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.
Comment on lines
+111
to
+114
| 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 <sylvainniles@microsoft.com>
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.
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: