Ruleset bypass_actors: base repository role names resolve to the wrong ids

Open Beginner friendly
#1,143 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
github, javascript, node.js
Domain
api, backend

Research direction

Start with lib/plugins/rulesets.js and inspect BASE_REPOSITORY_ROLE_IDS and the code that handles RepositoryRole bypass actors. Confirm the repository role IDs against the issue's GraphQL reproduction details, then check nearby tests for role mapping and invalid roles. Done means the supported names resolve to the reported IDs and read and triage produce a clear error.

Written by the indexing model from the issue text.

Description

Problem

BASE_REPOSITORY_ROLE_IDS in lib/plugins/rulesets.js (added in #990) maps read: 1, triage: 2, write: 3, maintain: 4, admin: 5. GitHub uses maintain: 2, write: 4, admin: 5, so only admin resolves correctly:

  • name: maintain resolves to 4, so everyone with write gets the bypass.
  • name: write resolves to 3, and GitHub rejects the ruleset: 422 Actor base role does not have write permissions.
  • name: triage resolves to 2, so maintain gets the bypass.

Reproduce

Create a repository ruleset with RepositoryRole bypass actors with ids 2, 4, and 5, then read them back through GraphQL (bypassActors { repositoryRoleName repositoryRoleDatabaseId }): 2 = maintain, 4 = write, 5 = admin. Ids 1 and 3 fail with the 422 above. The Terraform provider docs list the same ids.

Suggested fix

Map maintain: 2, write: 4, admin: 5, and reject read and triage with a clear error, since GitHub doesn't allow them as bypass actors.

Dominant language
JavaScript
Stars
942
Forks
238
PR merge metrics
No merged PRs in 30d

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from github-community-projects/safe-settings

All issues in github-community-projects/safe-settings

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.