Return proper InvalidArgument messages like s3 for invalid data for ListObjects(), ListObjectParts(), ListMultipartUploads()

master
Harshavardhana 9 years ago
parent 9d525ecadc
commit 5eae32f2b0
  1. 8
      pkg/server/api/bucket-handlers.go
  2. 26
      pkg/server/api/errors.go
  3. 8
      pkg/server/api/object-handlers.go

@ -88,6 +88,10 @@ func (api Minio) ListMultipartUploadsHandler(w http.ResponseWriter, req *http.Re
}
resources := getBucketMultipartResources(req.URL.Query())
if resources.MaxUploads < 0 {
writeErrorResponse(w, req, InvalidMaxUploads, acceptsContentType, req.URL.Path)
return
}
if resources.MaxUploads == 0 {
resources.MaxUploads = maxObjectList
}
@ -155,6 +159,10 @@ func (api Minio) ListObjectsHandler(w http.ResponseWriter, req *http.Request) {
}
resources := getBucketResources(req.URL.Query())
if resources.Maxkeys < 0 {
writeErrorResponse(w, req, InvalidMaxKeys, acceptsContentType, req.URL.Path)
return
}
if resources.Maxkeys == 0 {
resources.Maxkeys = maxObjectList
}

@ -52,6 +52,10 @@ const (
InvalidDigest
InvalidRange
InvalidRequest
InvalidMaxKeys
InvalidMaxUploads
InvalidMaxParts
InvalidPartNumberMarker
MalformedXML
MissingContentLength
MissingRequestBodyError
@ -69,11 +73,31 @@ const (
// Error codes, non exhaustive list - standard HTTP errors
const (
NotAcceptable = iota + 25
NotAcceptable = iota + 29
)
// Error code to Error structure map
var errorCodeResponse = map[int]Error{
InvalidMaxUploads: {
Code: "InvalidArgument",
Description: "Argument maxUploads must be an integer between 0 and 2147483647",
HTTPStatusCode: http.StatusBadRequest,
},
InvalidMaxKeys: {
Code: "InvalidArgument",
Description: "Argument maxKeys must be an integer between 0 and 2147483647",
HTTPStatusCode: http.StatusBadRequest,
},
InvalidMaxParts: {
Code: "InvalidArgument",
Description: "Argument maxParts must be an integer between 1 and 10000 ",
HTTPStatusCode: http.StatusBadRequest,
},
InvalidPartNumberMarker: {
Code: "InvalidArgument",
Description: "Argument partNumberMarker must be an integer",
HTTPStatusCode: http.StatusBadRequest,
},
AccessDenied: {
Code: "AccessDenied",
Description: "Access Denied",

@ -473,6 +473,14 @@ func (api Minio) ListObjectPartsHandler(w http.ResponseWriter, req *http.Request
}
objectResourcesMetadata := getObjectResources(req.URL.Query())
if objectResourcesMetadata.PartNumberMarker < 0 {
writeErrorResponse(w, req, InvalidPartNumberMarker, acceptsContentType, req.URL.Path)
return
}
if objectResourcesMetadata.MaxParts < 0 {
writeErrorResponse(w, req, InvalidMaxParts, acceptsContentType, req.URL.Path)
return
}
if objectResourcesMetadata.MaxParts == 0 {
objectResourcesMetadata.MaxParts = maxPartsList
}

Loading…
Cancel
Save