diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2021-08-31 11:55:41 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2021-09-08 12:32:34 +0300 |
commit | 949c3634b1c4b8f8ec739eb9d7a6ea313383d8b5 (patch) | |
tree | ed582ab64f8ca390ec5476603cdf2df4855ae791 | |
parent | 8b2e73ee1fe8f69f47872f8616fa133d4901b3bd (diff) |
repository: Convert SetFullPath to use proper helpers for gRPC errors
Use the error formatting variants of helper functions instead of using
`helper.ErrInternal(fmt.Errorf(...))`. This also fixes a bug where gRPC
error codes weren't returned properly.
-rw-r--r-- | internal/gitaly/service/repository/fullpath.go | 7 | ||||
-rw-r--r-- | internal/gitaly/service/repository/fullpath_test.go | 2 |
2 files changed, 4 insertions, 5 deletions
diff --git a/internal/gitaly/service/repository/fullpath.go b/internal/gitaly/service/repository/fullpath.go index 1c22f0815..23532d98c 100644 --- a/internal/gitaly/service/repository/fullpath.go +++ b/internal/gitaly/service/repository/fullpath.go @@ -2,7 +2,6 @@ package repository import ( "context" - "fmt" "gitlab.com/gitlab-org/gitaly/v14/internal/helper" "gitlab.com/gitlab-org/gitaly/v14/proto/go/gitalypb" @@ -27,15 +26,15 @@ func (s *server) SetFullPath( repo := s.localrepo(request.GetRepository()) if err := s.voteOnConfig(ctx, request.GetRepository()); err != nil { - return nil, helper.ErrInternal(fmt.Errorf("preimage vote on config: %w", err)) + return nil, helper.ErrInternalf("preimage vote on config: %w", err) } if err := repo.Config().Set(ctx, fullPathKey, request.GetPath()); err != nil { - return nil, helper.ErrInternal(fmt.Errorf("writing config: %w", err)) + return nil, helper.ErrInternalf("writing config: %w", err) } if err := s.voteOnConfig(ctx, request.GetRepository()); err != nil { - return nil, helper.ErrInternal(fmt.Errorf("postimage vote on config: %w", err)) + return nil, helper.ErrInternalf("postimage vote on config: %w", err) } return &gitalypb.SetFullPathResponse{}, nil diff --git a/internal/gitaly/service/repository/fullpath_test.go b/internal/gitaly/service/repository/fullpath_test.go index 883e313fe..9642fb653 100644 --- a/internal/gitaly/service/repository/fullpath_test.go +++ b/internal/gitaly/service/repository/fullpath_test.go @@ -74,7 +74,7 @@ func TestSetFullPath(t *testing.T) { require.Nil(t, response) - expectedErr := fmt.Sprintf("rpc error: code = Internal desc = writing config: rpc "+ + expectedErr := fmt.Sprintf("rpc error: code = NotFound desc = writing config: rpc "+ "error: code = NotFound desc = GetRepoPath: not a git repository: %q", repoPath) require.EqualError(t, err, expectedErr) }) |