From 737e2b3210bd3e7ede79ec1e04faf1b03a060c75 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 18 Jan 2023 20:54:57 +0100 Subject: [PATCH] Fix 500 error viewing pull request when fork has pull requests disabled (#22512) Swallow error just like in #20839, for the case where there is no protected branch. Fixes #20826 for me, though I can't tell if this now covers all cases. --- services/pull/update.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/services/pull/update.go b/services/pull/update.go index bd4880a2fc7a0..8aed60e070fde 100644 --- a/services/pull/update.go +++ b/services/pull/update.go @@ -109,6 +109,9 @@ func IsUserAllowedToUpdate(ctx context.Context, pull *issues_model.PullRequest, if pr.ProtectedBranch == nil { prUnit, err := pr.BaseRepo.GetUnit(unit.TypePullRequests) if err != nil { + if repo_model.IsErrUnitTypeNotExist(err) { + return false, false, nil + } log.Error("pr.BaseRepo.GetUnit(unit.TypePullRequests): %v", err) return false, false, err }