diff options
author | Norman Soetbeer <norman.soetbeer@gmail.com> | 2023-10-11 22:24:29 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-11 20:24:29 +0000 |
commit | 0e204b730aa2b1fa0835336b1117eff8c420f713 (patch) | |
tree | e1cb44e7d54e347e57ea9c5b3c95dc529b1d1d22 /admin.go | |
parent | fae195ac7eb9f4b0e9436384cd0529a11355e367 (diff) |
admin: Respond with 4xx on non-existing config path (#5870)
Co-authored-by: Matt Holt <mholt@users.noreply.github.com>
Diffstat (limited to 'admin.go')
-rw-r--r-- | admin.go | 16 |
1 files changed, 14 insertions, 2 deletions
@@ -1196,15 +1196,27 @@ traverseLoop: } case http.MethodPut: if _, ok := v[part]; ok { - return fmt.Errorf("[%s] key already exists: %s", path, part) + return APIError{ + HTTPStatus: http.StatusConflict, + Err: fmt.Errorf("[%s] key already exists: %s", path, part), + } } v[part] = val case http.MethodPatch: if _, ok := v[part]; !ok { - return fmt.Errorf("[%s] key does not exist: %s", path, part) + return APIError{ + HTTPStatus: http.StatusNotFound, + Err: fmt.Errorf("[%s] key does not exist: %s", path, part), + } } v[part] = val case http.MethodDelete: + if _, ok := v[part]; !ok { + return APIError{ + HTTPStatus: http.StatusNotFound, + Err: fmt.Errorf("[%s] key does not exist: %s", path, part), + } + } delete(v, part) default: return fmt.Errorf("unrecognized method %s", method) |