fix(crt): fail request on HTTP 200 with error body#7071
Open
arnabnandy7 wants to merge 1 commit into
Open
Conversation
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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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'sCompleteMultipartUploadAPI), the client was silently reporting success and completing the future withnull. 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
handleServiceErrorto fail the response handler and the future exceptionally ifisSuccessStatus(responseStatus)is true.isSuccessStatus(int responseStatus)to detect 2xx status codes.errorResponseWith200Status_shouldCompleteFutureExceptionallyunit test to verify that the future is completed exceptionally when S3 returns an error with HTTP status 200.Testing
Tested locally using JUnit 5:
S3CrtResponseHandlerAdapterTestwhich includes the new test case confirming that HTTP 200 with an error payload throwsS3Exception.Command run:
.\mvnw.cmd test -pl :s3 "-Dtest=S3CrtResponseHandlerAdapterTest" "-Dspotbugs.skip=true" "-Dcheckstyle.skip=true" "-Dfindbugs.skip=true"Screenshots (if appropriate)
Types of changes
Checklist
mvn installsucceedsscripts/new-changescript and following the instructions. Commit the new file created by the script in.changes/next-releasewith your changes.License