Skip to content

Intermittent issue where S3 upload appears successful (200 OK) but object is missing #6007

@emmymatt

Description

@emmymatt

Describe the bug

We are uploading a file to S3 using a logic similar to the second example shown in the official documentation.

Here’s the relevant snippet:

try (BufferedInputStream bis = new BufferedInputStream(getInputStream())) {
    String fileName = URLEncoder.encode(this.fileName, STANDARD_CHARSET);
    PutObjectRequest putRequest = getPutRequestBuilder()
        .key(s3Key)
        .contentDisposition("filename=" + fileName)
        .build();

    BlockingInputStreamAsyncRequestBody body = AsyncRequestBody.forBlockingInputStream(null);
    UploadRequest uploadRequest = UploadRequest.builder()
        .requestBody(body)
        .putObjectRequest(putRequest)
        .build();

    Upload upload = batchDownloadConnection.s3TransferManager().upload(uploadRequest);
    body.writeInputStream(bis);

    PutObjectResponse response = upload.completionFuture().join().response();
    return response;
}

Issue:

Intermittently, we’re seeing that the uploaded file is not present in the bucket, even though the response we receive from the SDK indicates a successful upload with HTTP 200 OK. This seems to be happening only in production environment.

Here is an example of such a response:

response = PutObjectResponse(
  Expiration=expiry-date="Mon, 05 May 2025 00:00:00 GMT", rule-id="[REDACTED]",
  ETag="ec02a428cb9a3ed88ac29ea47f45820b",
  ChecksumCRC32=1HnwtQ==,
  ServerSideEncryption=AES256
),
responseMetadata = {
  Content-Length=[0],
  Date=[Fri, 04 Apr 2025 05:40:50 GMT],
  ETag=["ec02a428cb9a3ed88ac29ea47f45820b"],
  Server=[AmazonS3],
  x-amz-checksum-crc32=[1HnwtQ==],
  x-amz-checksum-type=[FULL_OBJECT],
  x-amz-expiration=[expiry-date="Mon, 05 May 2025 00:00:00 GMT", rule-id="[REDACTED]"],
  x-amz-id-2=[REDACTED],
  x-amz-request-id=[REDACTED],
  x-amz-server-side-encryption=[AES256]
},
statusText=Optional[OK],
statusCode=200
As you can see, the SDK returns a valid ETag and a 200 response. However, when we look into the bucket, the file is missing.

The AWS request ID is included above (x-amz-request-id=[REDACTED]).

Could you please investigate this behavior?

AWS SDK version: 2.27.21
AWS SDK STS version: 2.17.52

Regression Issue

  • Select this option if this issue appears to be a regression.

Expected Behavior

The file should be reliably uploaded to S3, and it should be available in the bucket when the upload.completionFuture().join() call completes and returns a 200 OK response without exception.

Current Behavior

Intermittently in production, even though the SDK returns a 200 OK response with a valid ETag, the file is not present in the S3 bucket afterward.

Reproduction Steps

We have not been able to reproduce this issue consistently in non-production environments. However, the logic we use is based on the streaming upload pattern provided in the AWS documentation

Possible Solution

No response

Additional Information/Context

No response

AWS Java SDK version used

2.27.21

JDK version used

17.0.7

Operating System and version

NA

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue is a bug.p2This is a standard priority issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions