HDDS-15304. DeleteObjects should enforce the request key limit#10309
Conversation
|
@peterxcli could you please review this patch. |
|
Sample output after the fix. |
|
|
||
| if (request.getObjects() != null | ||
| && request.getObjects().size() > S3Consts.S3_DELETE_OBJECTS_MAX_KEYS) { | ||
| throw newError(S3ErrorTable.MALFORMED_XML, bucketName); |
There was a problem hiding this comment.
I think we should throw clear exception
| throw newError(S3ErrorTable.MALFORMED_XML, bucketName); | |
| throw newError(S3ErrorTable.INVALID_ARGUMENT, "too many objects"); |
There was a problem hiding this comment.
Test case multiDeleteRejectsMoreThanMaxKeysPerRequest will need to be updated as well.
There was a problem hiding this comment.
I think it would be better to keep MALFORMED_XML and maybe add reason along with it instead of INVALID_ARGUMENT
aws/aws-sdk#602 (comment)
There was a problem hiding this comment.
@peterxcli could you please let me know which would be better to have INVALID_ARGUMENT or MALFORMED_XML because looks like aws uses MALFORMED_XML not sure if it later changed it.
we could probably update the message like follows:
throw newError(S3ErrorTable.MALFORMED_XML, bucketName)
.withMessage(S3ErrorTable.MALFORMED_XML.getErrorMessage()
+ ". A maximum of " + S3Consts.S3_DELETE_OBJECTS_MAX_KEYS
+ " objects may be specified per request.");
There was a problem hiding this comment.
@sreejasahithi thanks for providing the specific issue link, after take deeper look I think you're right.
The existing ceph s3-test test case only assert the http code
https://ozone.s3.peterxcli.dev/?q=delete_bucket&run=2026-06-15T07-46-21Z&caseSuite=s3_tests&test=test_multi_object_delete_key_limit#search-section
I've checked the minio archive code, and it indeed return MALFORMED_XML for this delete object limit exceed case.
https://github.com/minio/minio/blob/7aac2a2c5b7c882e68c1ce017d8256be2feea27f/cmd/bucket-handlers.go#L472-L476
| OS3Exception ex = assertThrows(OS3Exception.class, | ||
| () -> rest.multiDelete("b1", "", mdr)); | ||
| assertEquals("MalformedXML", ex.getCode()); | ||
| assertEquals(HTTP_BAD_REQUEST, ex.getHttpCode()); |
There was a problem hiding this comment.
nit: can simplify using EndpointTestUtils.assertErrorResponse
assertErrorResponse(S3ErrorTable.INVALID_ARGUMENT, () -> rest.multiDelete("b1", "", mdr));(changed error code suggested by @peterxcli)
peterxcli
left a comment
There was a problem hiding this comment.
Thanks @sreejasahithi for the update, LGTM +1
|
|
||
| if (request.getObjects() != null | ||
| && request.getObjects().size() > S3Consts.S3_DELETE_OBJECTS_MAX_KEYS) { | ||
| throw newError(S3ErrorTable.MALFORMED_XML, bucketName); |
There was a problem hiding this comment.
@sreejasahithi thanks for providing the specific issue link, after take deeper look I think you're right.
The existing ceph s3-test test case only assert the http code
https://ozone.s3.peterxcli.dev/?q=delete_bucket&run=2026-06-15T07-46-21Z&caseSuite=s3_tests&test=test_multi_object_delete_key_limit#search-section
I've checked the minio archive code, and it indeed return MALFORMED_XML for this delete object limit exceed case.
https://github.com/minio/minio/blob/7aac2a2c5b7c882e68c1ce017d8256be2feea27f/cmd/bucket-handlers.go#L472-L476
bf57f6a to
dd9f3d7
Compare
|
Thanks @sreejasahithi for the patch, @adoroszlai for the review! |
What changes were proposed in this pull request?
The multi object delete iterates all request entries and forwards them to bucket.deleteKeys without checking the S3 1000 key maximum limit.
It should reject DeleteObjects requests with more than 1000 objects before execution and return the error.
What is the link to the Apache JIRA
HDDS-15304
How was this patch tested?
Added testcases
Green CI : https://github.com/sreejasahithi/ozone/actions/runs/26077522597