Skip to content

fix(crt): fail request on HTTP 200 with error body#7071

Open
arnabnandy7 wants to merge 1 commit into
aws:masterfrom
arnabnandy7:fix/s3-multipart-silent-error
Open

fix(crt): fail request on HTTP 200 with error body#7071
arnabnandy7 wants to merge 1 commit into
aws:masterfrom
arnabnandy7:fix/s3-multipart-silent-error

Conversation

@arnabnandy7

Copy link
Copy Markdown

Motivation and Context

When using the CRT-backed S3AsyncClient, if an S3-compatible server returns HTTP 200 in the response header but an <Error> XML payload in the body (a documented behavior of S3's CompleteMultipartUpload API), the client was silently reporting success and completing the future with null. This prevented the client from detecting the failure and caused undetectable data loss.

This change ensures that error responses returned with a 2xx success status code are correctly treated as failures, completing the response future exceptionally with an S3Exception.

Fixes #7068

Modifications

  • S3CrtResponseHandlerAdapter.java:
    • Updated handleServiceError to fail the response handler and the future exceptionally if isSuccessStatus(responseStatus) is true.
    • Added a private helper method isSuccessStatus(int responseStatus) to detect 2xx status codes.
  • S3CrtResponseHandlerAdapterTest.java:
    • Added the errorResponseWith200Status_shouldCompleteFutureExceptionally unit test to verify that the future is completed exceptionally when S3 returns an error with HTTP status 200.

Testing

Tested locally using JUnit 5:

  • Ran S3CrtResponseHandlerAdapterTest which includes the new test case confirming that HTTP 200 with an error payload throws S3Exception.
    Command run: .\mvnw.cmd test -pl :s3 "-Dtest=S3CrtResponseHandlerAdapterTest" "-Dspotbugs.skip=true" "-Dcheckstyle.skip=true" "-Dfindbugs.skip=true"
  • All 9 unit tests passed successfully.

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist

  • I have read the CONTRIBUTING document
  • Local run of mvn install succeeds
  • My code follows the code style of this project
  • My change requires a change to the Javadoc documentation
  • I have updated the Javadoc documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed
  • I have added a changelog entry. Adding a new entry must be accomplished by running the scripts/new-change script and following the instructions. Commit the new file created by the script in .changes/next-release with your changes.
  • My change is to implement 1.11 parity feature and I have updated LaunchChangelog

License

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

Ensure the CRT-backed S3AsyncClient fails the future instead of silently reporting success when S3 returns an HTTP 2xx response but with an XML error payload (e.g. for complete multipart upload failures).
@arnabnandy7 arnabnandy7 requested a review from a team as a code owner June 24, 2026 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CRT: client silently reports success for failed multipart uploads when S3 returns HTTP 200 with error body, causing undetectable data loss

1 participant