This repository was archived by the owner on Sep 30, 2024. It is now read-only.
fix: grant pending permissions not working correctly#50059
Merged
Conversation
GrantPendingPermissions can be called multiple times in a loop. When using unified perms, it uses a method that by default removed old records from the table, effectively replacing existing records with new records. However this behavior is not correct for granting pending permissions, which should only add new records, not remove old ones. Fixing this allows us to call GrantPendingPermissions in a loop without causing incosistencies in the database.
Contributor
|
Codenotify: Notifying subscribers in CODENOTIFY files for diff 80771f4...4c90545.
|
erzhtor
approved these changes
Mar 28, 2023
| return s.setUserExternalAccountPerms(ctx, user, repoIDs, source, true) | ||
| } | ||
|
|
||
| func (s *permsStore) setUserExternalAccountPerms(ctx context.Context, user authz.UserIDWithExternalAccountID, repoIDs []int32, source authz.PermsSource, deleteOldPerms bool) (*database.SetPermissionsResult, error) { |
Contributor
There was a problem hiding this comment.
Minor renaming suggestion deleteOldPerms -> replaceRoles.
github-actions Bot
pushed a commit
that referenced
this pull request
Mar 28, 2023
## Description GrantPendingPermissions can be called multiple times in a loop. When using unified perms, it uses a method that by default removed old records from the table, effectively replacing existing records with new records. However this behavior is not correct for granting pending permissions, which should only add new records, not remove old ones. Fixing this allows us to call GrantPendingPermissions in a loop without causing incosistencies in the database. ## Test plan extensively unit tested so that we are sure it works for both legacy and unified permissions (cherry picked from commit d7ca3ca)
coury-clark
pushed a commit
that referenced
this pull request
Mar 28, 2023
…50073) ## Description GrantPendingPermissions can be called multiple times in a loop. When using unified perms, it uses a method that by default removed old records from the table, effectively replacing existing records with new records. However this behavior is not correct for granting pending permissions, which should only add new records, not remove old ones. Fixing this allows us to call GrantPendingPermissions in a loop without causing incosistencies in the database. ## Test plan extensively unit tested so that we are sure it works for both legacy and unified permissions <br> Backport d7ca3ca from #50059 Co-authored-by: Milan Freml <kopancek@users.noreply.github.com>
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Description
GrantPendingPermissions can be called multiple times in a loop. When using unified perms, it uses a method that by default removed old records from the table, effectively replacing existing records with new records.
However this behavior is not correct for granting pending permissions, which should only add new records, not remove old ones. Fixing this allows us to call GrantPendingPermissions in a loop without causing incosistencies in the database.
Test plan
extensively unit tested so that we are sure it works for both legacy and unified permissions