X Tutup
The Wayback Machine - https://web.archive.org/web/20201104012332/https://github.com/PyGithub/PyGithub/issues/1686
Skip to content
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

Adding a team with permission to a repository is failing #1686

Open
RaghunathLingutla opened this issue Sep 8, 2020 · 3 comments
Open

Adding a team with permission to a repository is failing #1686

RaghunathLingutla opened this issue Sep 8, 2020 · 3 comments

Comments

@RaghunathLingutla
Copy link

@RaghunathLingutla RaghunathLingutla commented Sep 8, 2020

Hi,
I have developed below code to add a team with admin permission, which was working fine, till two to three weeks ago. Suddenly same code is failing with error.

from github import Github

g = Github(personal_token)
org = g.get_organization(organization_name)
repo_obj = org.get_repo('test-repo-add-team')

team = org.get_team(team_id)
team.set_repo_permission(repo_obj, 'Admin')
print(f'Added data team to test-repo-add-team')

Below is the error message,
Traceback (most recent call last):
File "/Test/github/adding_team_to_repo.py", line 7, in
team.set_repo_permission(repo_obj, 'Admin')
File /Test/venv/lib/site-packages/github/Team.py", line 249, in set_repo_permission
"PUT", self.url + "/repos/" + repo._identity, input=put_parameters
File "/Test/venv/lib/site-packages/github/Requester.py", line 319, in requestJsonAndCheck
verb, url, parameters, headers, input, self.__customConnection(url)
File "/Test/venv/lib/site-packages/github/Requester.py", line 342, in __check
raise self.__createException(status, responseHeaders, output)
github.GithubException.GithubException: 422 {"message": "Validation Failed", "documentation_url": "https://docs.github.com/rest/reference/teams#add-or-update-team-repository-permissions"}

@Aricg
Copy link

@Aricg Aricg commented Oct 7, 2020

Same.

                  print(team.id)
                  team.add_to_repos(repo_actual) # <-works, adds team as read only)
                  team.set_repo_permission(repo_actual, "write") #<- no longer updates team to write permission

github.GithubException.GithubException: 422 {"message": "Validation Failed", "documentation_url": "https://docs.github.com/rest/reference/teams#add-or-update-team-repository-permissions"}

@Aricg
Copy link

@Aricg Aricg commented Oct 8, 2020

Looking into this it appears that the api method is deprecated.

https://docs.github.com/en/free-pro-team@latest/rest/reference/teams#add-or-update-team-project-permissions-legacy
Deprecation Notice: This endpoint route is deprecated and will be removed from the Teams API. We recommend migrating your existing code to use the new Add or update team project permissions endpoint.

The new method is
https://developer.github.com/v3/teams/#add-or-update-team-project-permissions
Which is in "Preview"

Why they would deprecate the old method while the new one is still in preview is anyone's guess..

@s-t-e-v-e-n-k
Copy link
Collaborator

@s-t-e-v-e-n-k s-t-e-v-e-n-k commented Oct 28, 2020

master now has merged a commit which adds Team.update_team_repository() which uses the new endpoint. You can try and use that and see if that works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.
X Tutup