Skip to content

Commit

Permalink
Add StatusConflict http kind to userErrorCodeMap
Browse files Browse the repository at this point in the history
  • Loading branch information
halimsam authored and k8s-infra-cherrypick-robot committed Oct 23, 2024
1 parent 8c21c23 commit f9c5c9f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/common/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 8 additions & 0 deletions pkg/common/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit f9c5c9f

Please sign in to comment.