From 38a4e2b4928864720cc2cd4a7e26b87fa4473cd5 Mon Sep 17 00:00:00 2001 From: zeripath Date: Thu, 18 Aug 2022 11:31:15 +0100 Subject: [PATCH] Prevent 500 is head repo does not have PullRequest unit in IsUserAllowedToUpdate (#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 --- services/pull/update.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/services/pull/update.go b/services/pull/update.go index e5e26462e5aa..49258a9862d1 100644 --- a/services/pull/update.go +++ b/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) if err != nil { + if repo_model.IsErrUnitTypeNotExist(err) { + return false, false, nil + } return false, false, err }