github-community-projects / github-community-projects/safe-settings

Cannot add teams to repo.yml

Open
#809 8 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
JavaScript
Stars
921
Forks
226
Avg merge
18h 3m
Merged PRs (30d)
14

Description

## Problem Description

### What's Happening

We're managing repository-level team permissions using individual repo YAML files (e.g., `Mobile.yml`, `Web.yml`, `infra.yml`) under the `.github/repos` directory. We **do not** maintain any team configurations in `settings.yml`.

The intent is to explicitly grant certain teams (like all engineering teams) permissions to deploy to non-prod environments. For example:

```yaml
# .github/repos/Prequal.yml

repository:
name: Prequal
teams:
- name: SRE
permission: maintain
- name: "Engineering Members"
permission: push
```

However, when applying these settings, we encounter the following error:

```
Error adding team: 422
```

API response:
```json
{
"message": "Validation Failed",
"errors": [
{
"resource": "Team",
"code": "unprocessable",
"field": "data",
"message": "Name must be unique for this org"
}
],
"documentation_url": "https://docs.github.com/rest/teams/teams#create-a-team",
"status": "422"
}
```

This seems to happen when the team already exists or is already associated with the repository.

### Expected Behavior

We want to know if there's a way to **skip adding a team** if it already exists or is already associated with the repository, to avoid the 422 error. Ideally, the settings app should be idempotent in this case.

---

## Context

- **GitHub App:** Self-hosted instance of `probot/settings`
- **Platform:** GitHub Enterprise (EMU)
- **Versions:**
- `probot/settings`: [please insert version]
- GitHub Enterprise: [please insert version]

---

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.