Browse Source

fix: add ErrUserNotFound and ErrPolicyNotFound to groupErrorToHTTPStatus

Map these sentinel errors to 404 so AddGroupMember and
AttachGroupPolicy return proper HTTP status codes.
pull/8560/head
Chris Lu 21 hours ago
parent
commit
2d783a5ba7
  1. 6
      weed/admin/handlers/group_handlers.go

6
weed/admin/handlers/group_handlers.go

@ -27,6 +27,12 @@ func groupErrorToHTTPStatus(err error) int {
if errors.Is(err, credential.ErrPolicyNotAttached) {
return http.StatusBadRequest
}
if errors.Is(err, credential.ErrUserNotFound) {
return http.StatusNotFound
}
if errors.Is(err, credential.ErrPolicyNotFound) {
return http.StatusNotFound
}
return http.StatusInternalServerError
}

Loading…
Cancel
Save