Skip to content

Fix DeleteObjects to throw DeleteObjectsException instead of AmazonS3Exception #3839

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: aws-sdk-net-v3.7-development
Choose a base branch
from

Conversation

AlexDaines
Copy link
Contributor

Description

Added UnmarshallException method override to DeleteObjectsResponseUnmarshaller to ensure that all DeleteObjects operation failures consistently throw DeleteObjectsException instead of the generic AmazonS3Exception.
The fix creates a DeleteObjectsResponse containing structured error information and wraps it in a DeleteObjectsException, preserving all error details (ErrorCode, RequestId, StatusCode) while providing the expected exception type.

Motivation and Context

Fixes issue #3828 reported inconsistent exception handling for DeleteObjects operations.

Testing

  • Tested with invalid keys (too long), confirming DeleteObjectsException is now thrown
  • Verified that exception contains proper error information in Response.DeleteErrors collection
  • Validated that ErrorCode, RequestId, and StatusCode are properly preserved

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project
  • My change requires a change to the documentation
  • I have updated the documentation accordingly
  • I have read the README document
  • I have added tests to cover my changes
  • All new and existing tests passed

License

  • I confirm that this pull request can be released under the Apache 2 license

@AlexDaines AlexDaines marked this pull request as ready for review May 22, 2025 17:47
@AlexDaines AlexDaines requested a review from normj May 22, 2025 17:47

// For standard S3 error responses (like KeyTooLongError), create a DeleteObjectsException
// with the error information wrapped in a DeleteObjectsResponse
var errorResponse = S3ErrorResponseUnmarshaller.Instance.Unmarshall(context);
Copy link

@grsw92 grsw92 May 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AlexDaines does this solution guarantee that object under valid key gets deleted when sent along with invalid key in a single DeleteObjectsRequest?

@dscpinheiro dscpinheiro added v4 v3 and removed v4 labels May 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants