Skip to content

Wrong response code from failed precondition If-None-Match #6023

Closed

Description

@bbraatCrwd

Describe the bug

When submitting a write to an object in S3 with the If-None-Match header set in the SDK, a 200 response code can occasionally be returned along with the expected Exception, rather than the expected 412 response code.

Regression Issue

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

Expected Behavior

I expect to see a 412 response code every time this pre-condition is not met. The flakiness of the response code makes handling the return more cumbersome.

Current Behavior

This is a possible Exception/response payload that can be returned on failing the pre-condition:
software.amazon.awssdk.services.s3.model.S3Exception: At least one of the pre-conditions you specified did not hold (Service: S3, Status Code: 200, Request ID: 9YD49V2HRSDRS8K1, Extended Request ID: jUpbn2VaLT6Kwi6vyaN32y1OOWX0ShIocGfV+9+I7qG7kmmAR7kVCA3WATwcjpDMPdTEg3hLPuI=)

Reproduction Steps

The issue happens intermittently on the S3 side and it is not clear how to reproduce.

Possible Solution

No response

Additional Information/Context

No response

AWS Java SDK version used

2.29.1

JDK version used

24

Operating System and version

Multiple environments

Activity

  1. added
    bug
    needs-triage
    on Apr 10, 2025
  2. debora-ito commented on Apr 11, 2025

    @debora-ito
    Member

    Reproduction Steps
    The issue happens intermittently on the S3 side and it is not clear how to reproduce.

    Understood. Can you provide a code snippet showing the s3 client and the GetObject request call, so I can try to reproduce the same conditions?

  3. added
    response-requested
    p2
    and removed
    needs-triage
    on Apr 11, 2025
  4. self-assigned this
    on Apr 11, 2025
  5. steveloughran commented on Apr 16, 2025

    @steveloughran

    so it is an exception being triggered -but the status code is 200?

    odd

  6. bbraatCrwd commented on Apr 16, 2025

    @bbraatCrwd
    Author

    Reproduction Steps
    The issue happens intermittently on the S3 side and it is not clear how to reproduce.

    Understood. Can you provide a code snippet showing the s3 client and the GetObject request call, so I can try to reproduce the same conditions?

    This is on upload, not download. The example I was looking at was on a multipart upload during one of the upload part calls:
    val uploadPartRequest = UploadPartRequest.builder() .bucket(bucket) .key(key) .uploadId(uploadId) .partNumber(partNumber) .contentMD5(chunkMd5) .contentLength(chunk.length) val body = AsyncRequestBody.fromBytesUnsafe(chunk) client.uploadPart(uploadPartRequest.build(), body)

  7. bbraatCrwd commented on Apr 16, 2025

    @bbraatCrwd
    Author

    so it is an exception being triggered -but the status code is 200?

    odd

    That is correct, we receive it like any other exception, but the status code is a 200 instead of the expected 412

  8. removed
    response-requested
    on Apr 16, 2025
  9. debora-ito commented on Apr 17, 2025

    @debora-ito
    Member

    @bbraatCrwd sorry, you're right, if-none-match makes no sense with read operations.
    Edit: actually if-match and if-none-match can be provided in GetObject calls, don't know why I was confused.

    I'm wondering if this is a s3 server-side issue - the SDK usually don't modify a response status code, according to the exception you pasted it looks like the 200 was sent by s3, the SDK is only unmarshalling the response. Maybe some edge case of what is described in the multipart upload scenario here.

    One way to confirm this is to generate the verbose wirelogs and get the actual response at the error moment (instructions for the verbose wirelogs can be found in our Dev Guide); the other is to reach out to the s3 team with your request ID (you'll need to provide a more recent one) and ask them to investigate. Let us know what you think.

  10. debora-ito commented on May 14, 2025

    @debora-ito
    Member

    @bbraatCrwd I tried to reproduce locally, calling CompleteMultipartUpload with if-none-match in loop, but I got status code 412 every time.

    Marking this to autoclose soon. If you get a request ID or the verbose wirelogs, please send to us and we can take a look.

  11. added
    closing-soon
    on May 14, 2025
  12. added and removed
    closing-soon
    on May 18, 2025
  13. debora-ito commented on May 28, 2025

    @debora-ito
    Member

    @bbraatCrwd I recently found this re:Post where it confirms S3 might return 200 with errors for CompleteMultipartUpload, CopyObject and UploadPartCopy API calls - https://repost.aws/knowledge-center/s3-resolve-200-internalerror

  14. rogerhu commented on Jun 23, 2026

    @rogerhu

    Marking this to autoclose soon. If you get a request ID or the verbose wirelogs, please send to us and we can take a look.

    We see:

    oftware.amazon.awssdk.services.s3.model.S3Exception: At least one of the pre-conditions you specified did not hold (Service: S3, Status Code: 200, Request ID: T4XW17Q58VE3JCHY, Extended Request ID: Ao2mjr9NiCtlLpA1zKgKdVGNYst7E44NBEUzNYikTXUY7ViOEMSiLe3jCy+WM+WpiYIcww0j3rz6CUA+fRC80g==) (SDK Attempt Count: 1)
    ---- cut here ---8<--------8<--------8<--------8<--- cut here ----
    java.io.IOException: Could not upload '<REDACTED BLOB KEY>` in region 'us-west-2': software.amazon.awssdk.services.s3.model.S3Exception: At least one of the pre-conditions you specified did not hold (Service: S3, Status Code: 200, Request ID: T4XW17Q58VE3JCHY, Extended Request ID: Ao2mjr9NiCtlLpA1zKgKdVGNYst7E44NBEUzNYikTXUY7ViOEMSiLe3jCy+WM+WpiYIcww0j3rz6CUA+fRC80g==) (SDK Attempt Count: 1)
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugclosed-for-stalenessp2

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions