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

Prevent an alias who is not a collaborator from failing to assign any aliases #5

Merged
merged 9 commits into from
Mar 12, 2024

Conversation

jamoor-moj
Copy link

@jamoor-moj jamoor-moj commented Mar 8, 2024

When the action attempts to assign a list of aliases as reviewers, the batch call will fail if any of the aliases are not a collaborator of the repository and therefore don't have access:

HttpError: Reviews may only be requested from collaborators. One or more of the teams you specified is not a collaborator of the <owner>/<repo> repository

The error does not provide information on which aliases are not collaborators, and the current GH Rest/GraphQL APIs do not have a "filtered list of collaborators" method. To retrieve collaborator status, we would either need to make an individual network call per alias, or retrieve all collaborators which could be pages of information returned.

The proposed fix is to simplify the approach and update the current rest call to not be a batch call. If a particular alias no longer contains access, the requestReviewers call will print out an error. However, the error will not stop execution (all collaborators get added) and the action will not register as failed.

@jamoor-moj jamoor-moj merged commit 034fb67 into master Mar 12, 2024
1 check passed
jamoor-moj added a commit that referenced this pull request Apr 9, 2024
jamoor-moj added a commit that referenced this pull request Apr 19, 2024
…Batch Call (#6)

In a previous PR (#5), the `request reviewer` call was converted from a batch call to multiple individual calls in order to support cases where an alias no longer has access to the repo.

In very rare circumstances, it has been reported that the action will actually remove add (and then automatically get removed) from the pull request. Since the action doesn't invoke any `remove reviewer` APIs, the only theory so far is that making multiple edit request simultaneously has exposed a rare syncronous problem, usually when combined with [auto assignment](https://docs.github.com/en/organizations/organizing-members-into-teams/managing-code-review-settings-for-your-team#about-auto-assignment). This scenario is rare enough that it has been difficult to get reproductions of the issue in test environments.

The proposed solution is to instead async request the permission status of every alias the action will attempt to add. After locally filtering out all aliases that do not have permissions, make a batch request with all of the remaining aliases. This adds 1 extra network call compared to the solution in 5, but reduces the number of network calls attempting to edit the PR down to 1.
@jamoor-moj jamoor-moj deleted the jamoor/collaborators branch April 19, 2024 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants