Skip to content

Commit 5d1d9e2

Browse files
committed
BUG/MINOR: Return the correct error code when adding duplicates into a map file
1 parent 0d057e2 commit 5d1d9e2

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

e2e/tests/acl_files/acl_file_entries.bats

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ load 'utils/_helpers'
5757
resource_post "$_RUNTIME_ACL_BASE_PATH/$PARENT_NAME/entries" "data/post.json"
5858
assert_equal "$SC" 201
5959
assert_equal "$(get_json_path "${BODY}" " .value" )" "/js"
60+
61+
# Adding the same entry twice should return a 409 error.
62+
resource_post "$_RUNTIME_ACL_BASE_PATH/$PARENT_NAME/entries" "data/post.json"
63+
assert_equal "$SC" 409
6064
}
6165

6266
@test "acl_runtime: Delete an ACL file entry by its ID" {

misc/misc.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ func HandleError(err error) *models.Error {
102102
code := ErrHTTPInternalServerError
103103
if errors.Is(t, client_errors.ErrNotFound) {
104104
code = ErrHTTPNotFound
105+
} else if errors.Is(t, client_errors.ErrAlreadyExists) {
106+
code = ErrHTTPConflict
105107
}
106108
return &models.Error{Code: &code, Message: &msg}
107109
}

0 commit comments

Comments
 (0)