From ab5c742e2b0fb7be8d7ea9910c31a237bd363ffb Mon Sep 17 00:00:00 2001 From: Alistair Coles Date: 2025年4月16日 12:16:00 +0100 Subject: [PATCH] s3api: make MPU part error response message same as S3 Change-Id: I60f0b36633c2a348933fd45d348d76b256fca57a --- swift/common/middleware/s3api/s3response.py | 6 +++--- test/s3api/test_mpu.py | 8 +++++--- test/unit/common/middleware/s3api/test_multi_upload.py | 7 +++++-- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/swift/common/middleware/s3api/s3response.py b/swift/common/middleware/s3api/s3response.py index 299bf30cef..fa7f81873a 100644 --- a/swift/common/middleware/s3api/s3response.py +++ b/swift/common/middleware/s3api/s3response.py @@ -472,9 +472,9 @@ class InvalidPartArgument(InvalidArgument): class InvalidPart(ErrorResponse): _status = '400 Bad Request' - _msg = 'One or more of the specified parts could not be found. The part ' \ - 'might not have been uploaded, or the specified entity tag might ' \ - 'not have matched the part\'s entity tag.' + _msg = '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.' class InvalidPartOrder(ErrorResponse): diff --git a/test/s3api/test_mpu.py b/test/s3api/test_mpu.py index 0827132fa1..42fd200fd3 100644 --- a/test/s3api/test_mpu.py +++ b/test/s3api/test_mpu.py @@ -848,9 +848,11 @@ class TestMultiPartUpload(BaseMultiPartUploadTestCase): 'ResponseMetadata']['HTTPStatusCode']) self.assertEqual('InvalidPart', complete_mpu_resp[ 'Error']['Code']) - self.assertTrue(complete_mpu_resp['Error']['Message'].startswith( - 'One or more of the specified parts could not be found.' - ), complete_mpu_resp['Error']['Message']) + self.assertEqual( + "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.", + complete_mpu_resp['Error']['Message']) self.assertEqual(complete_mpu_resp['Error']['UploadId'], upload_id) self.assertIn(complete_mpu_resp['Error']['PartNumber'], ('1', '2')) self.assertEqual(complete_mpu_resp['Error']['ETag'], None) diff --git a/test/unit/common/middleware/s3api/test_multi_upload.py b/test/unit/common/middleware/s3api/test_multi_upload.py index 6b52e60d5a..422f742544 100644 --- a/test/unit/common/middleware/s3api/test_multi_upload.py +++ b/test/unit/common/middleware/s3api/test_multi_upload.py @@ -1888,8 +1888,11 @@ class TestS3ApiMultiUpload(BaseS3ApiMultiUpload, S3ApiTestCase): fromstring(body, 'Error') self.assertEqual(status.split()[0], '200') self.assertEqual(self._get_error_code(body), 'InvalidPart') - self.assertIn('One or more of the specified parts could not be found', - self._get_error_message(body)) + self.assertEqual( + "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.", + self._get_error_message(body)) self.assertEqual(self.swift.calls, [ ('HEAD', '/v1/AUTH_test'), ('HEAD', '/v1/AUTH_test/bucket'),

AltStyle によって変換されたページ (->オリジナル) /