Skip to content

S3 conditional write PutObject request does not work correctly with implicit retries #6580

@findepi

Description

@findepi

Describe the bug

One can use conditional writes with either PutObject or CompleteMultipartUpload to effectively put object only if it doesn't exist yet (If-None-Match: *).

This works great in principle. This fails when there is a network issue and AWS SDK implicitly retries the underlying request:

  1. first request goes through and reaches the server, creating the object
  2. the response does not make it to the client though
  3. the client retries the request
  4. this second request fails with HTTP Status-Code 412: Precondition Failed

Regression Issue

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

Expected Behavior

PutObject should remain idempotent also when If-None-Match: * condition is used, as far as retries done by the library are concerned.
in other words, the application layer should be able to use If-None-Match: * write condition without doing a lot additional work on the calling side

Current Behavior

PutObject If-None-Match: * write condition leads to application errors when networking circumstances lead to a request being retried on the calling side.

Reproduction Steps

Any PutObject that sets software.amazon.awssdk.services.s3.model.PutObjectRequest.Builder.ifNoneMatch to * can be used to reproduce the issue, but full reproduction requires injecting network failures.

If this helps, i can try to produce such a test case with shopify/toxiproxy. Let me know if I should spend time on this.

Possible Solution

Tagging put objects creations with something that can identify them on the retried request.

Additional Information/Context

No response

AWS Java SDK version used

2.39.1

JDK version used

25

Operating System and version

MacOS 15.6

Metadata

Metadata

Assignees

Labels

bugThis issue is a bug.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions