From a86c2e2ce1eaca870c09f613a8de297578423f3a Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Sat, 17 Jun 2017 11:20:39 -0700 Subject: [PATCH] xl/fs: Return InvalidPart{} error for part ETag mismatch. (#4541) Fixes #4539 --- cmd/api-errors.go | 2 +- cmd/fs-v1-multipart.go | 2 +- cmd/object-api-errors.go | 2 +- cmd/object-api-multipart_test.go | 2 +- cmd/object-handlers_test.go | 2 +- cmd/xl-v1-multipart.go | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cmd/api-errors.go b/cmd/api-errors.go index 4a10bbdb5..76112d84b 100644 --- a/cmd/api-errors.go +++ b/cmd/api-errors.go @@ -317,7 +317,7 @@ var errorCodeResponse = map[APIErrorCode]APIError{ }, ErrInvalidPart: { Code: "InvalidPart", - Description: "One or more of the specified parts could not be found.", + Description: "One or more of the specified parts could not be found. The part may not have been uploaded, or the specified entity tag may not match the part's entity tag.", HTTPStatusCode: http.StatusBadRequest, }, ErrInvalidPartOrder: { diff --git a/cmd/fs-v1-multipart.go b/cmd/fs-v1-multipart.go index 25d253714..faee68dc7 100644 --- a/cmd/fs-v1-multipart.go +++ b/cmd/fs-v1-multipart.go @@ -808,7 +808,7 @@ func (fs fsObjects) CompleteMultipartUpload(bucket string, object string, upload if fsMeta.Parts[partIdx].ETag != part.ETag { fs.rwPool.Close(fsMetaPathMultipart) - return ObjectInfo{}, traceError(BadDigest{}) + return ObjectInfo{}, traceError(InvalidPart{}) } // All parts except the last part has to be atleast 5MB. diff --git a/cmd/object-api-errors.go b/cmd/object-api-errors.go index d77d85470..eba47a496 100644 --- a/cmd/object-api-errors.go +++ b/cmd/object-api-errors.go @@ -307,7 +307,7 @@ func (e InvalidUploadID) Error() string { type InvalidPart struct{} func (e InvalidPart) Error() string { - return "One or more of the specified parts could not be found" + return "One or more of the specified parts could not be found. The part may not have been uploaded, or the specified entity tag may not match the part's entity tag." } // PartTooSmall - error if part size is less than 5MB. diff --git a/cmd/object-api-multipart_test.go b/cmd/object-api-multipart_test.go index 36be3f8a2..4a6281657 100644 --- a/cmd/object-api-multipart_test.go +++ b/cmd/object-api-multipart_test.go @@ -1895,7 +1895,7 @@ func testObjectCompleteMultipartUpload(obj ObjectLayer, instanceType string, t T // Part number 0 doesn't exist, expecting InvalidPart error (Test number 12). {bucketNames[0], objectNames[0], uploadIDs[0], []completePart{{ETag: "abcd", PartNumber: 0}}, "", InvalidPart{}, false}, // // Upload and PartNumber exists, But a deliberate ETag mismatch is introduced (Test number 13). - {bucketNames[0], objectNames[0], uploadIDs[0], inputParts[0].parts, "", BadDigest{}, false}, + {bucketNames[0], objectNames[0], uploadIDs[0], inputParts[0].parts, "", InvalidPart{}, false}, // Test case with non existent object name (Test number 14). {bucketNames[0], "my-object", uploadIDs[0], []completePart{{ETag: "abcd", PartNumber: 1}}, "", InvalidUploadID{UploadID: uploadIDs[0]}, false}, // Testing for Part being too small (Test number 15). diff --git a/cmd/object-handlers_test.go b/cmd/object-handlers_test.go index 4c48f303e..bfe9b676a 100644 --- a/cmd/object-handlers_test.go +++ b/cmd/object-handlers_test.go @@ -2252,7 +2252,7 @@ func testAPICompleteMultipartHandler(obj ObjectLayer, instanceType, bucketName s accessKey: credentials.AccessKey, secretKey: credentials.SecretKey, - expectedContent: encodeResponse(getAPIErrorResponse(getAPIError(toAPIErrorCode(BadDigest{})), + expectedContent: encodeResponse(getAPIErrorResponse(getAPIError(toAPIErrorCode(InvalidPart{})), getGetObjectURL("", bucketName, objectName))), expectedRespStatus: http.StatusBadRequest, }, diff --git a/cmd/xl-v1-multipart.go b/cmd/xl-v1-multipart.go index 6d58c5b97..f8f135e92 100644 --- a/cmd/xl-v1-multipart.go +++ b/cmd/xl-v1-multipart.go @@ -936,7 +936,7 @@ func (xl xlObjects) CompleteMultipartUpload(bucket string, object string, upload // All parts should have same ETag as previously generated. if currentXLMeta.Parts[partIdx].ETag != part.ETag { - return ObjectInfo{}, traceError(BadDigest{}) + return ObjectInfo{}, traceError(InvalidPart{}) } // All parts except the last part has to be atleast 5MB.