Repository navigation
Optimize Actors.IsActor check - #1116
Merged
bluekeyes merged 1 commit intoNov 25, 2025
Merged
Conversation
Generate changelog in
|
✅ Successfully generated changelog entry!Need to regenerate?Simply interact with the changelog bot comment again to regenerate these entries. 🔄 Changelog entries were re-generated at Tue, 25 Nov 2025 17:56:06 UTC!📋Changelog Preview💡 Improvements
|
bluekeyes
approved these changes
Nov 25, 2025
bluekeyes
left a comment
Contributor
There was a problem hiding this comment.
Thanks! I agree that CollaboratorPermission does not have any side effects that are relevant to the behavior here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related to #1030.
Before this PR
In
Actors.IsActor,GitHubContext.CollaboratorPermissionis called unnecessarily, which consumes extra rate limits.After this PR
In
Actors.IsActor,GitHubContext.CollaboratorPermissionis only called when needed.As the table below shows, the behavior should be the same as before, except for the unnecessary API call eliminated where
Permissionsis not used.userPerm != pull.PermissionNoneuserPerm == pull.PermissionNonelen(permissions) > 0len(permissions) == 0Possible downsides?
Whether the call to
CollaboratorPermissionhas any "side effects" needs to be carefully considered, especially in the case where the user does not have permission in the repository.The actual implementation of
CollaboratorPermission(not the test one) is here:policy-bot/pull/github.go
Lines 648 to 698 in a4ac11a
To breakdown the implementation:
Therefore, we believe that removing the call to
CollaboratorPermissionwhenGetPermissions()is empty, should not have any downsides.We would like the review to double check this assumption, in addition to all the usual reviews.