Unable to switch default_branch of a repository using GitHub Apps Installation Token #62371
Replies: 2 comments
-
Did you ever find a solution for this @jjayabal23? I've just run into the same issue, I even have contents write permission and can can lookup the new branch name via https://docs.github.com/en/rest/git/refs?apiVersion=2022-11-28#get-a-reference fine but the change default branch request still fails. I also run into a similar issue if I try to rename the default branch which the docs say is possible. |
Beta Was this translation helpful? Give feedback.
-
I've figured it out, it seems you need both repository admin as well as org admin permissions on the GitHub App, just one or the other fails with this error. Smells like someone stuffed up and included the wrong admin ACL check somewhere along the line as I can't imagine why this would require org admin rights to change the default branch of a repo and the docs make no mention of this either. |
Beta Was this translation helpful? Give feedback.
-
Select Topic Area
Bug
Body
I have a GitHub App with the following Repository Permission,
Administration
>>Read & Write
I have generated a GitHub App installation token using octokit.net and tried calling the PATCH /repos/owner/repo to switch the default_branch to master, but the API returns the following error with status code 422 although the master branch already exists,
Request:
Response:
The same API works fine when I use a PAT of a User / Collaborator. Switching default_branch was working until 28/07/2023 and started throwing the above error thereafter.
Expected:
GitHub App should have the capapbility to switch the default_branch of a repository for which the Administrator Read & Write permissions for the repository is enabled.
Beta Was this translation helpful? Give feedback.
All reactions