Skip to content

Cannot add teams to repo.yml #809

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
bheemvennapureddy opened this issue Apr 9, 2025 · 6 comments
Open

Cannot add teams to repo.yml #809

bheemvennapureddy opened this issue Apr 9, 2025 · 6 comments
Labels
bug Something isn't working

Comments

@bheemvennapureddy
Copy link
Contributor

bheemvennapureddy commented Apr 9, 2025

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:

# .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:

{
  "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]

@bheemvennapureddy bheemvennapureddy added the bug Something isn't working label Apr 9, 2025
@bheemvennapureddy
Copy link
Contributor Author

@decyjphr Can you add some thoughts ?

@decyjphr
Copy link
Collaborator

decyjphr commented Apr 9, 2025

@bheemvennapureddy the teams element must be at the same level as repository in the repo.yml

Is that the case in your setting?

It should be something like this:

# .github/repos/Prequal.yml

repository:
  name: Prequal
  ...

teams:
  - name: SRE
    permission: maintain
  - name: "Engineering Members"
      permission: push

@bheemvennapureddy
Copy link
Contributor Author

bheemvennapureddy commented Apr 9, 2025

@decyjphr

Image

they are at the same level

@bheemvennapureddy
Copy link
Contributor Author

It always only complains about the "Engneering Members" team it never complained about "SRE" Team. Below is the safe settings finishes with SRE Team.

Image

Here is the error when we add "Engineering Members" Team

Image

logs show 422 error

@decyjphr
Copy link
Collaborator

@bheemvennapureddy I tried to recreate it but I couldn't. I tested by adding 2 or more teams in the repo.yml and I could see the teams being created. I must be missing something specific to your case. Does the team being added have security-manager role?

@bmike78
Copy link

bmike78 commented Apr 17, 2025

@bheemvennapureddy instead of using "Engineering Members" as the team name, you might want to use the team name that github understands like "engineering-managers".. whatever the team name is called in the team URL if that makes sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants