Honor role_name in runtime role authorization for on.roles (maintain/triage) - #37959
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
role_name in runtime role authorization for on.roles (maintain/triage)
There was a problem hiding this comment.
Pull request overview
This pull request fixes a schema/runtime mismatch in the JavaScript pre-activation authorization logic by honoring the GitHub collaborator API’s role_name (when present) instead of relying solely on permission, making maintain and triage roles reachable in real runtime authorization decisions.
Changes:
- Updated
checkRepositoryPermissionto compute aneffectiveRolefromrole_name(preferred, includingmaintainer → maintainalias) with fallback topermission. - Adjusted permission-check test fixtures to reflect realistic collaborator API responses that include both
permissionandrole_name. - Added coverage to verify
role_nametakes precedence overpermissionwhen they differ.
Show a summary per file
| File | Description |
|---|---|
| actions/setup/js/check_permissions_utils.cjs | Derives and authorizes against an effectiveRole using role_name when available; logs both when they differ. |
| actions/setup/js/check_permissions_utils.test.cjs | Updates fixtures and adds a precedence test to ensure role_name is authoritative. |
| actions/setup/js/check_permissions.test.cjs | Updates fixtures to model real collaborator responses for maintain/triage scenarios. |
| actions/setup/js/check_membership.test.cjs | Updates maintainer/maintain alias fixture to use realistic permission + role_name shape. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 4/4 changed files
- Comments generated: 0
|
✅ Design Decision Gate 🏗️ completed the design decision gate check. No ADR enforcement needed: PR #37959 does not have the 'implementation' label and has 0 new lines of code in business logic directories (threshold is 100). |
|
🧠 Matt Pocock Skills Reviewer failed during the skills-based review. |
|
|
|
🧪 Test Quality Sentinel completed test quality analysis. |
🧪 Test Quality Sentinel Report✅ Test Quality Score: 96/100 — Excellent
📊 Metrics & Test Classification (7 tests analyzed)
Test Classification Details
Language SupportTests analyzed:
Verdict
📖 Understanding Test ClassificationsDesign Tests (High Value) verify what the system does:
Implementation Tests (Low Value) verify how the system does it:
Goal: Shift toward tests that describe the system's behavioral contract — the promises it makes to its users and collaborators. References: §27172683290
|
There was a problem hiding this comment.
✅ Test Quality Sentinel: 96/100. Test quality is excellent — 0% of new tests are implementation tests (threshold: 30%). All 7 modified/new tests verify observable behavioral contracts, with 6/7 directly exercising the key edge case this PR addresses.
|
@copilot run pr-finisher skill (ignore impacted tests failure) |
Local validation is green ( The only CI failure is Ready for merge pending a human CI re-trigger (close/reopen PR or |
…yPermission Custom organization repository roles (e.g. "Security Champions") return a non-standard role_name from the GitHub API alongside a base permission (e.g. "write"). The previous logic used role_name exclusively when present, causing these roles to be rejected since their name doesn't match any on.roles enum value. Fix: for standard GitHub roles (admin, maintain, write, triage, read) keep exact role_name matching (preserving #37959's maintain/triage precision). For custom org roles, also check the base permission so that an actor whose custom role confers write is authorized when write is in the required set. Adds two test cases covering: (1) custom role authorized via base permission, (2) custom role rejected when base permission is insufficient. Closes #45536 Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
on.rolesallowedmaintainandtriagein schema, but runtime authorization matched onlypermission, making those values effectively unreachable in real API responses. This change aligns runtime behavior with schema by resolving roles using the collaborator API’srole_namewhen present.Runtime authorization alignment
checkRepositoryPermissionto derive aneffectiveRolefrom:role_name(preferred, normalizedmaintainer -> maintain)permissionwhenrole_nameis absenteffectiveRole, removing the schema-valid-but-unreachable gap.API-shape-consistent fixtures
permissionandrole_name(e.g.,permission: "write", role_name: "maintain").maintaineraccepted asmaintain).Focused coverage for precedence semantics
role_nameis authoritative when it differs frompermission(e.g., denyroles: [write]whenrole_nameismaintaineven ifpermissioniswrite).