diff --git a/pkg/api/api_bucket_handlers.go b/pkg/api/api_bucket_handlers.go index 299269eb9..341648519 100644 --- a/pkg/api/api_bucket_handlers.go +++ b/pkg/api/api_bucket_handlers.go @@ -73,6 +73,11 @@ func (server *minioAPI) listObjectsHandler(w http.ResponseWriter, req *http.Requ { writeErrorResponse(w, req, NoSuchKey, acceptsContentType, req.URL.Path) } + default: + { + log.Error.Println(err) + writeErrorResponse(w, req, InternalError, acceptsContentType, req.URL.Path) + } } } @@ -83,6 +88,7 @@ func (server *minioAPI) listObjectsHandler(w http.ResponseWriter, req *http.Requ func (server *minioAPI) listBucketsHandler(w http.ResponseWriter, req *http.Request) { acceptsContentType := getContentType(req) buckets, err := server.driver.ListBuckets() + // cannot fallthrough in (type) switch :( switch err := err.(type) { case nil: { @@ -96,7 +102,7 @@ func (server *minioAPI) listBucketsHandler(w http.ResponseWriter, req *http.Requ } case drivers.BackendCorrupted: { - log.Error.Println("Backend Corrupted") + log.Error.Println(err) writeErrorResponse(w, req, InternalError, acceptsContentType, req.URL.Path) } default: @@ -139,6 +145,12 @@ func (server *minioAPI) putBucketHandler(w http.ResponseWriter, req *http.Reques } case drivers.ImplementationError: { + log.Error.Println(err) + writeErrorResponse(w, req, InternalError, acceptsContentType, req.URL.Path) + } + default: + { + log.Error.Println(err) writeErrorResponse(w, req, InternalError, acceptsContentType, req.URL.Path) } } diff --git a/pkg/api/api_object_handlers.go b/pkg/api/api_object_handlers.go index 6b649d639..493e590e0 100644 --- a/pkg/api/api_object_handlers.go +++ b/pkg/api/api_object_handlers.go @@ -84,6 +84,11 @@ func (server *minioAPI) getObjectHandler(w http.ResponseWriter, req *http.Reques { writeErrorResponse(w, req, InvalidBucketName, acceptsContentType, req.URL.Path) } + case drivers.ImplementationError: + { + log.Error.Println(err) + writeErrorResponse(w, req, InternalError, acceptsContentType, req.URL.Path) + } default: { log.Error.Println(err) @@ -105,8 +110,10 @@ func (server *minioAPI) headObjectHandler(w http.ResponseWriter, req *http.Reque metadata, err := server.driver.GetObjectMetadata(bucket, object, "") switch err := err.(type) { case nil: - setObjectHeaders(w, metadata) - w.WriteHeader(http.StatusOK) + { + setObjectHeaders(w, metadata) + w.WriteHeader(http.StatusOK) + } case drivers.ObjectNotFound: { writeErrorResponse(w, req, NoSuchKey, acceptsContentType, req.URL.Path) @@ -120,6 +127,11 @@ func (server *minioAPI) headObjectHandler(w http.ResponseWriter, req *http.Reque log.Error.Println(err) writeErrorResponse(w, req, InternalError, acceptsContentType, req.URL.Path) } + default: + { + log.Error.Println(err) + writeErrorResponse(w, req, InternalError, acceptsContentType, req.URL.Path) + } } } @@ -174,5 +186,10 @@ func (server *minioAPI) putObjectHandler(w http.ResponseWriter, req *http.Reques { writeErrorResponse(w, req, InvalidDigest, acceptsContentType, req.URL.Path) } + default: + { + log.Error.Println(err) + writeErrorResponse(w, req, InternalError, acceptsContentType, req.URL.Path) + } } } diff --git a/pkg/drivers/donut/donut.go b/pkg/drivers/donut/donut.go index 248b95296..c1ceecd7b 100644 --- a/pkg/drivers/donut/donut.go +++ b/pkg/drivers/donut/donut.go @@ -118,6 +118,13 @@ func (d donutDriver) GetPartialObject(w io.Writer, bucket, object string, start, // GetObjectMetadata retrieves an object's metadata func (d donutDriver) GetObjectMetadata(bucket, key string, prefix string) (drivers.ObjectMetadata, error) { metadata, err := d.donut.GetObjectMetadata(bucket, key) + if err != nil { + // return ObjectNotFound quickly on an error, API needs this to handle invalid requests + return drivers.ObjectMetadata{}, drivers.ObjectNotFound{ + Bucket: bucket, + Object: key, + } + } created, err := time.Parse(time.RFC3339Nano, metadata["sys.created"]) if err != nil { return drivers.ObjectMetadata{}, err