Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <psteinhardt@gitlab.com>2022-03-11 13:42:33 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2022-03-11 13:42:33 +0300
commit6c63998ad459ff840e82e636c93d2aa7e25fe982 (patch)
tree60d14ace6109aa51b4a2146581d429c050bd31e9
parent7e4ced45a42379d240661115c613912d318a1de1 (diff)
operations: Fix wrong error code when UserSquash conflictspks-user-squash-fix-error-code-with-improved-error-handling
With the new improved error hadnling in UserSquash we're now returning errors in some cases where we previously didn't. One of those cases is when the rebase performed during the squash results in a merge conflict. While it is correct to return an error in this case, we're using an Internal error code for this case, which indicates that Gitaly is to blame instead of the parameters which have been passed by the user. Fix the error code to instead be FailedPrecondition. This error code is special-cased by our monitoring infrastructure to not raise any alerts. Note that this change is only fixing issues with monitoring: Rails handles the error alright by inspecting the error details instead of the error code. Changelog: fixed
-rw-r--r--internal/gitaly/service/operations/squash.go2
-rw-r--r--internal/gitaly/service/operations/squash_test.go2
2 files changed, 2 insertions, 2 deletions
diff --git a/internal/gitaly/service/operations/squash.go b/internal/gitaly/service/operations/squash.go
index 4a942a15e..b73bc58ba 100644
--- a/internal/gitaly/service/operations/squash.go
+++ b/internal/gitaly/service/operations/squash.go
@@ -193,7 +193,7 @@ func (s *Server) userSquash(ctx context.Context, req *gitalypb.UserSquashRequest
}
detailedErr, err := helper.ErrWithDetails(
- helper.ErrInternalf("rebasing commits: %w", err),
+ helper.ErrFailedPreconditionf("rebasing commits: %w", err),
&gitalypb.UserSquashError{
Error: &gitalypb.UserSquashError_RebaseConflict{
RebaseConflict: &gitalypb.MergeConflictError{
diff --git a/internal/gitaly/service/operations/squash_test.go b/internal/gitaly/service/operations/squash_test.go
index 668503535..d0b111215 100644
--- a/internal/gitaly/service/operations/squash_test.go
+++ b/internal/gitaly/service/operations/squash_test.go
@@ -520,7 +520,7 @@ func testUserSquashConflicts(t *testing.T, ctx context.Context) {
if featureflag.UserSquashImprovedErrorHandling.IsEnabled(ctx) {
testhelper.RequireGrpcError(t, errWithDetails(t,
- helper.ErrInternalf("rebasing commits: rebase: commit %q: there are conflicting files", ours),
+ helper.ErrFailedPreconditionf("rebasing commits: rebase: commit %q: there are conflicting files", ours),
&gitalypb.UserSquashError{
Error: &gitalypb.UserSquashError_RebaseConflict{
RebaseConflict: &gitalypb.MergeConflictError{