diff options
author | Steve Azzopardi <sazzopardi@gitlab.com> | 2022-07-21 12:47:59 +0300 |
---|---|---|
committer | Steve Azzopardi <sazzopardi@gitlab.com> | 2022-07-21 13:01:49 +0300 |
commit | 798a57d8e9e731489ea9c47051d29b1ebcaf699b (patch) | |
tree | 117e75bda34e491efea5de5225d4b1b82cc6860f | |
parent | f8e688fbf64938cf8563f765c040af39f33e0790 (diff) |
Change FindTag err when tag not found to NotFound
What
---
Update the error message to be `Not Found` rather then `Internal` when a
tag is not found.
Why
---
We burn through our error budget when a single user sends a bunch of
requests to tags that don't exist because we classify the error as
`Internal`, instead it should be `NotFound`.
Reference: https://gitlab.com/gitlab-org/gitaly/-/issues/4366
Signed-off-by: Steve Azzopardi <sazzopardi@gitlab.com>
-rw-r--r-- | internal/gitaly/service/ref/refs.go | 2 | ||||
-rw-r--r-- | internal/gitaly/service/ref/refs_test.go | 12 |
2 files changed, 13 insertions, 1 deletions
diff --git a/internal/gitaly/service/ref/refs.go b/internal/gitaly/service/ref/refs.go index 19e532dc0..c8b1ba34d 100644 --- a/internal/gitaly/service/ref/refs.go +++ b/internal/gitaly/service/ref/refs.go @@ -257,7 +257,7 @@ func (s *server) findTag(ctx context.Context, repo git.RepositoryExecutor, tagNa return nil, err } } else { - return nil, errors.New("no tag found") + return nil, helper.ErrNotFoundf("no tag found") } if err = tagCmd.Wait(); err != nil { diff --git a/internal/gitaly/service/ref/refs_test.go b/internal/gitaly/service/ref/refs_test.go index aa4e0faff..2028563e9 100644 --- a/internal/gitaly/service/ref/refs_test.go +++ b/internal/gitaly/service/ref/refs_test.go @@ -1212,3 +1212,15 @@ func TestInvalidFindTagRequest(t *testing.T) { }) } } + +func TestNotFoundFindTagRequest(t *testing.T) { + t.Parallel() + + ctx := testhelper.Context(t) + _, repoProto, _, client := setupRefService(ctx, t) + + rpcRequest := &gitalypb.FindTagRequest{Repository: repoProto, TagName: []byte("not-found")} + + _, err := client.FindTag(ctx, rpcRequest) + testhelper.RequireGrpcError(t, err, helper.ErrNotFoundf("no tag found")) +} |