Prevent 500 is head repo does not have PullRequest unit in IsUserAllowedToUpdate (#20839)

Some repositories do not have the PullRequest unit present in their configuration
and unfortunately the way that IsUserAllowedToUpdate currently works assumes
that this is an error instead of just returning false.

This PR simply swallows this error allowing the function to return false.

Fix #20621

Signed-off-by: Andrew Thornton <art27@cantab.net>

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
tokarchuk/v1.18
zeripath 2 years ago committed by GitHub
parent 999392f6a5
commit 0724ca451e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      services/pull/update.go

@ -87,6 +87,9 @@ func IsUserAllowedToUpdate(ctx context.Context, pull *issues_model.PullRequest,
} }
headRepoPerm, err := access_model.GetUserRepoPermission(ctx, pull.HeadRepo, user) headRepoPerm, err := access_model.GetUserRepoPermission(ctx, pull.HeadRepo, user)
if err != nil { if err != nil {
if repo_model.IsErrUnitTypeNotExist(err) {
return false, false, nil
}
return false, false, err return false, false, err
} }

Loading…
Cancel
Save