From 054fa09e147949da0ae26065d798bc84141be6ae Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Wed, 4 Aug 2021 08:46:36 +0200 Subject: operations: Validate early whether UserFFBranch got a repository We're currently relying on the fact that any of the called functions in UserFFBranch will return an error if the request's repository is unset. This is quite fragile and is bound to break as soon as the logic of UserFFBranch changes. Fix this by validating early whether the request has a repository or not. --- internal/gitaly/service/operations/merge.go | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'internal/gitaly/service/operations/merge.go') diff --git a/internal/gitaly/service/operations/merge.go b/internal/gitaly/service/operations/merge.go index 79e1598e7..7303c4f1b 100644 --- a/internal/gitaly/service/operations/merge.go +++ b/internal/gitaly/service/operations/merge.go @@ -137,6 +137,10 @@ func (s *Server) UserMergeBranch(stream gitalypb.OperationService_UserMergeBranc } func validateFFRequest(in *gitalypb.UserFFBranchRequest) error { + if in.Repository == nil { + return fmt.Errorf("empty repository") + } + if len(in.Branch) == 0 { return fmt.Errorf("empty branch name") } -- cgit v1.2.3