You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
gh pr edit --remove-reviewer does not work when removing all reviewers #10958
If I execute the command through my account on the CLI and I'm not part of the team I'm trying to remove it seems to work fine. So it seems to be related to the actor's membership status in the team?
I tried using a GitHub app from within a GitHub action to not trigger it through my account, but the action also seems to run into the same problem of not being able to remove the team that I'm apart of.
I'm also the author of the PR in question - might this be part of the problem?
I looked into this and I could reproduce it. The gist is there's an if-statement that aborts the process of updating reviewers if the final slices of both user reviewers and team reviewers are empty, which is not correct because in your case (and what I tried) the user wants to drop all reviewers. Here's the code piece I'm talking about:
I could temporarily fix this by dropping the len(.)==0 conditions, but I think the code needs a bit more polishing, especially the pointer-to-slice implementation which is not a Go idiomatic way of handling slices.
@tobias-tengler, to make sure I'm not missing any other factors here, could you please also share with me the output of running the command below? Please redact unnecessary details/secrets.
Given I have a PR with only a user reviewer assigned to it When I run gh pr edit --remove-reviewer <user> Then the PR is updated and has no reviewers
Removing team reviewer
Given I have a PR with only a team reviewer assigned to it When I run gh pr edit --remove-reviewer <org>/<team> Then the PR is updated and has no reviewers
Removing both
Given I have a PR with both a user and a team reviewer assigned to it When I run gh pr edit --remove-reviewer <user>,<org>/<team> Then the PR is updated and has no reviewers
This confirms what I'm referring to. There is no mutation request for updating the reviewers in the trail, just like what I observed on my end. It should have something like this near the end of the trail (which will drop all reviewers assigned).
To reiterate on your original issue, it's not with the teams. It happens whenever you're removing all reviewers regardless of their type (user or team). For example, if you have a PR with just a single user reviewer assigned to it, removing that reviewer would also fail.
I didn't even think that it could be related to the number of reviewers, because I thought there already was another reviewing team 🤦♂️
Turns out it was just the preview of a team that would get added as CODEOWNERS once I published the PR.
This also explains why it was working for me with another team, since I was adding that team in addition to the team I was trying to remove, so there actually would've been a team left, once the other team was removed.
So it seems to be caused by the issue that you've found!
Turns out it was just the preview of a team that would get added as CODEOWNERS once I published the PR.
This also explains why it was working for me with another team, since I was adding that team in addition to the team I was trying to remove, so there actually would've been a team left, once the other team was removed.
changed the title [-]gh pr edit --remove-reviewer does not work for teams[/-][+]gh pr edit --remove-reviewer does not work when removing all reviewers[/+]on May 14, 2025
Activity
tobias-tengler commentedon May 9, 2025
If I execute the command through my account on the CLI and I'm not part of the team I'm trying to remove it seems to work fine. So it seems to be related to the actor's membership status in the team?
I tried using a GitHub app from within a GitHub action to not trigger it through my account, but the action also seems to run into the same problem of not being able to remove the team that I'm apart of.
I'm also the author of the PR in question - might this be part of the problem?
babakks commentedon May 12, 2025
Thanks for reporting this issue, @tobias-tengler!
I looked into this and I could reproduce it. The gist is there's an
if-statement that aborts the process of updating reviewers if the final slices of both user reviewers and team reviewers are empty, which is not correct because in your case (and what I tried) the user wants to drop all reviewers. Here's the code piece I'm talking about:cli/pkg/cmd/pr/edit/edit.go
Lines 281 to 289 in 90532e8
I could temporarily fix this by dropping the
len(.)==0conditions, but I think the code needs a bit more polishing, especially the pointer-to-slice implementation which is not a Go idiomatic way of handling slices.@tobias-tengler, to make sure I'm not missing any other factors here, could you please also share with me the output of running the command below? Please redact unnecessary details/secrets.
babakks commentedon May 12, 2025
Here's the A/C based on my observations, so far.
Acceptance Criteria
Removing user reviewer
Given I have a PR with only a user reviewer assigned to it
When I run
gh pr edit --remove-reviewer <user>Then the PR is updated and has no reviewers
Removing team reviewer
Given I have a PR with only a team reviewer assigned to it
When I run
gh pr edit --remove-reviewer <org>/<team>Then the PR is updated and has no reviewers
Removing both
Given I have a PR with both a user and a team reviewer assigned to it
When I run
gh pr edit --remove-reviewer <user>,<org>/<team>Then the PR is updated and has no reviewers
tobias-tengler commentedon May 12, 2025
Thanks for looking into this @babakks!
Here's the censored output if I run your command:
Output
babakks commentedon May 12, 2025
Thanks for the prompt reply, @tobias-tengler! 🙏
This confirms what I'm referring to. There is no mutation request for updating the reviewers in the trail, just like what I observed on my end. It should have something like this near the end of the trail (which will drop all reviewers assigned).
To reiterate on your original issue, it's not with the teams. It happens whenever you're removing all reviewers regardless of their type (user or team). For example, if you have a PR with just a single user reviewer assigned to it, removing that reviewer would also fail.
tobias-tengler commentedon May 12, 2025
I didn't even think that it could be related to the number of reviewers, because I thought there already was another reviewing team 🤦♂️

Turns out it was just the preview of a team that would get added as CODEOWNERS once I published the PR.
This also explains why it was working for me with another team, since I was adding that team in addition to the team I was trying to remove, so there actually would've been a team left, once the other team was removed.
So it seems to be caused by the issue that you've found!
babakks commentedon May 12, 2025
Makes sense. Thanks for confirmation.
babakks commentedon May 13, 2025
@tobias-tengler, I have created #10975 to fix this issue.
If you like, you can try building from source (the PR's branch) and check if the changes work for you.
babakks commentedon May 13, 2025
@tobias-tengler The fix has been merged and will be available in the next release.
[-]gh pr edit --remove-reviewer does not work for teams[/-][+]gh pr edit --remove-reviewer does not work when removing all reviewers[/+]