github / github/ruleset-recipes

Recreating the example from README throws the error: "Error importing ruleset: The ruleset you are importing contains an invalid actor"

Aperta
#39 2 commenti 1 reazione 0 assegnatari Vedi su GitHub
Lingua principale
Nessun dato sulla lingua
Stelle
495
Fork
143
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

## Describe the bug
Importing the `branch-rulesets/PRs and commits.json` rulesets throws an error.

## To Reproduce
1. Clone this repo.
2. Open a repo with admin rights.
3. Go to Settings -> Rules -> Rulesets.
4. Import the ruleset `branch-rulesets/PRs and commits.json` as shown in the video example from this repo.

## Expected behavior
The ruleset gets imported as shown in the video without throwing any errors.

## Actual behavior
The following error is thrown:

```
Error importing ruleset: The ruleset you are importing contains an invalid actor
```

## Screenshots/Video
Image

https://github.com/user-attachments/assets/b900ce93-ea42-407d-940d-47d01042e6ed

## Environment
- OS: macOS
- Browser: Chrome

## Additional Context
Possible source of the error:
- My Github account is a [personal account](https://docs.github.com/en/get-started/learning-about-github/types-of-github-accounts#personal-accounts).
- According to the [Github Docs](https://docs.github.com/en/rest/orgs/rules?versionId=free-pro-team%40latest&page=enums&apiVersion=2022-11-28#create-an-organization-repository-ruleset--parameters) (see "Properties of `bypass_actors` -> `actor_id`"), the `"actor_type": "OrganizationAdmin"` used in the [`PRs and commits.json#L44`](https://github.com/github/ruleset-recipes/blob/82adf8954a5cafb9722c18c421b9834c24ec0cd0/branch-rulesets/PRs%20and%20commits.json#L44) file is not applicable for personal repositories.
- FWIW I was able to import the rule _after_ deleting the `bypass_actors` property from the [`PRs and commits.json` file](https://github.com/github/ruleset-recipes/blob/82adf8954a5cafb9722c18c421b9834c24ec0cd0/branch-rulesets/PRs%20and%20commits.json).
- Manually adding the bypass actors and exporting the ruleset revealed the following `bypass_actors` block where the actor IDs 2, 4, 5 correspond to `maintain`, `write`, and `admin` respectively as discussed [here](https://github.com/github/rest-api-description/issues/4406#issuecomment-2580627194).
```json
"bypass_actors": [
{
"actor_id": 2,
"actor_type": "RepositoryRole",
"bypass_mode": "always"
},
{
"actor_id": 4,
"actor_type": "RepositoryRole",
"bypass_mode": "always"
},
{
"actor_id": 5,
"actor_type": "RepositoryRole",
"bypass_mode": "always"
}
]
```

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia con branch-rulesets/PRs e commits.json, in particolare con la voce bypass_actors intorno alla riga 44, e confrontala con gli esempi di RepositoryRole esportati nell’issue. Riproduci l’importazione per un repository personale e verifica che la recipe revisionata venga importata senza l’errore invalid-actor, mantenendo il comportamento di bypass previsto.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
github
Ambito
security
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Tranquilla
Chiarezza
Abbastanza chiara
Idoneità per principianti
48/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.