From 30d4fd427fc63daef560f1608b3833b827ab54ac Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Tue, 7 Jun 2022 15:04:46 +0200 Subject: operations: Use structured errors in UserDeleteBranch UserDeleteBranch is returning successfully in some error cases. This is a pattern we want to get rid of, so let's convert the RPC to instead use the structured errors via the new `UserDeleteBranchError` message type. This fixes some cases where we know to create replication jobs because the `UserDeleteBranch` RPC returns successfully, but didn't cast a single vote. Changelog: fixed --- proto/go/gitalypb/operations_grpc.pb.go | 22 ++++++++++++++++------ proto/operations.proto | 11 ++++++++--- 2 files changed, 24 insertions(+), 9 deletions(-) (limited to 'proto') diff --git a/proto/go/gitalypb/operations_grpc.pb.go b/proto/go/gitalypb/operations_grpc.pb.go index 3ee7dabeb..0171226c2 100644 --- a/proto/go/gitalypb/operations_grpc.pb.go +++ b/proto/go/gitalypb/operations_grpc.pb.go @@ -28,9 +28,14 @@ type OperationServiceClient interface { // // - Returns `InvalidArgument` in case either the branch name or user are not set. // - Returns `FailedPrecondition` in case the branch does not exist. - // - Returns `OK` with a `PreReceiveError` in case custom hooks refused the update. - // - Returns `FailedPrecondition` in case updating the reference fails because of a concurrent - // write to the same reference. + // - Returns `OK` with a `PreReceiveError` in case custom hooks refused the update. If the + // `gitaly_user_delete_branch_structured_errors` feature flag is enabled this error case will + // instead return `PermissionDenied` with either a `CustomHook` or AccessCheck` structured + // error. + // - Returns `FailedPrecondition` in case updating the reference fails because + // of a concurrent write to the same reference. If the + // `gitaly_user_delete_branch_structured_errors` feature flag is set this error case will + // instead return `FailedPrecondition` with a `ReferenceUpdate` structured error. UserDeleteBranch(ctx context.Context, in *UserDeleteBranchRequest, opts ...grpc.CallOption) (*UserDeleteBranchResponse, error) // UserCreateTag creates a new tag. UserCreateTag(ctx context.Context, in *UserCreateTagRequest, opts ...grpc.CallOption) (*UserCreateTagResponse, error) @@ -338,9 +343,14 @@ type OperationServiceServer interface { // // - Returns `InvalidArgument` in case either the branch name or user are not set. // - Returns `FailedPrecondition` in case the branch does not exist. - // - Returns `OK` with a `PreReceiveError` in case custom hooks refused the update. - // - Returns `FailedPrecondition` in case updating the reference fails because of a concurrent - // write to the same reference. + // - Returns `OK` with a `PreReceiveError` in case custom hooks refused the update. If the + // `gitaly_user_delete_branch_structured_errors` feature flag is enabled this error case will + // instead return `PermissionDenied` with either a `CustomHook` or AccessCheck` structured + // error. + // - Returns `FailedPrecondition` in case updating the reference fails because + // of a concurrent write to the same reference. If the + // `gitaly_user_delete_branch_structured_errors` feature flag is set this error case will + // instead return `FailedPrecondition` with a `ReferenceUpdate` structured error. UserDeleteBranch(context.Context, *UserDeleteBranchRequest) (*UserDeleteBranchResponse, error) // UserCreateTag creates a new tag. UserCreateTag(context.Context, *UserCreateTagRequest) (*UserCreateTagResponse, error) diff --git a/proto/operations.proto b/proto/operations.proto index 5ecf78553..927dc67a8 100644 --- a/proto/operations.proto +++ b/proto/operations.proto @@ -35,9 +35,14 @@ service OperationService { // // - Returns `InvalidArgument` in case either the branch name or user are not set. // - Returns `FailedPrecondition` in case the branch does not exist. - // - Returns `OK` with a `PreReceiveError` in case custom hooks refused the update. - // - Returns `FailedPrecondition` in case updating the reference fails because of a concurrent - // write to the same reference. + // - Returns `OK` with a `PreReceiveError` in case custom hooks refused the update. If the + // `gitaly_user_delete_branch_structured_errors` feature flag is enabled this error case will + // instead return `PermissionDenied` with either a `CustomHook` or AccessCheck` structured + // error. + // - Returns `FailedPrecondition` in case updating the reference fails because + // of a concurrent write to the same reference. If the + // `gitaly_user_delete_branch_structured_errors` feature flag is set this error case will + // instead return `FailedPrecondition` with a `ReferenceUpdate` structured error. rpc UserDeleteBranch(UserDeleteBranchRequest) returns (UserDeleteBranchResponse) { option (op_type) = { op: MUTATOR -- cgit v1.2.3