Skip to content

Commit

Permalink
Prevent 500 is head repo does not have PullRequest unit in IsUserAllo…
Browse files Browse the repository at this point in the history
…wedToUpdate (#20839)

Backport #20621

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>
  • Loading branch information
zeripath committed Aug 18, 2022
1 parent c40c753 commit 38a4e2b
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions services/pull/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ func IsUserAllowedToUpdate(ctx context.Context, pull *issues_model.PullRequest,
}
headRepoPerm, err := access_model.GetUserRepoPermission(ctx, pull.HeadRepo, user)
if err != nil {
if repo_model.IsErrUnitTypeNotExist(err) {
return false, false, nil
}
return false, false, err
}

Expand Down

0 comments on commit 38a4e2b

Please sign in to comment.