From f9c5c9f7acf93dfdb53af488f74d90a1579f8c8c Mon Sep 17 00:00:00 2001 From: Samuel Halim Date: Tue, 22 Oct 2024 23:37:14 +0000 Subject: [PATCH] Add StatusConflict http kind to userErrorCodeMap --- pkg/common/utils.go | 1 + pkg/common/utils_test.go | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/pkg/common/utils.go b/pkg/common/utils.go index c3b71c1c4..a69d30453 100644 --- a/pkg/common/utils.go +++ b/pkg/common/utils.go @@ -98,6 +98,7 @@ var ( http.StatusBadRequest: codes.InvalidArgument, http.StatusTooManyRequests: codes.ResourceExhausted, http.StatusNotFound: codes.NotFound, + http.StatusConflict: codes.FailedPrecondition, } // Regular expressions for validating parent_id, key and value of a resource tag. diff --git a/pkg/common/utils_test.go b/pkg/common/utils_test.go index 1b9b44e30..0df0ed1d1 100644 --- a/pkg/common/utils_test.go +++ b/pkg/common/utils_test.go @@ -1241,6 +1241,14 @@ func TestCodeForError(t *testing.T) { }), expCode: codes.NotFound, }, + { + name: "googleapi.Error that wraps apierror.APIError of http kind status conflict", + inputErr: getGoogleAPIWrappedError(&googleapi.Error{ + Code: 409, + Message: "status conflict error", + }), + expCode: codes.FailedPrecondition, + }, { name: "googleapi.Error that wraps apierror.APIError of status kind", inputErr: getGoogleAPIWrappedError(status.New(