Skip to content

GetObjectCommand throws Error named "304" instead of "NotModified" for If-None-Match with matching ETag #5860

@DougReeder

Description

@DougReeder

Checkboxes for prior research

Describe the bug

When I use GetObjectCommand with the IfNoneMatch parameter set to the ETag that matches the current value of the object, I get an unexpected error:

{
  "name": "304",
  "$fault": "client",
  "$metadata": {
    "httpStatusCode": 304,
    "requestId": "txf0dab84e1901420c995fe-0065e8c28e",
    "extendedRequestId": "txf0dab84e1901420c995fe-0065e8c28e",
    "attempts": 1,
    "totalRetryDelay": 0
  },
  "message": "UnknownError"
}

According to the docs it should return return a "304 Not Modified error". I can work around this oddity, but it would be nice to have this error named consistently with other.

SDK version number

@aws-sdk/package-name@3.523.0

Which JavaScript Runtime is this issue in?

Node.js

Details of the browser/Node.js/ReactNative version

v20.10.0

Reproduction Steps

try { 
    let getParam = { Bucket: username, Key: s3Path, IfNoneMatch: condition.ETag };

  const { Body, ETag, ContentType, ContentLength } = await this.#S3Client.send(new GetObjectCommand(getParam));
    //...
} catch (err) {
    if (err.name === 'NotModified' ) {
        return { status: 304, readStream: null, contentType: null, contentLength: null, ETag: null    };
    } else {
        throw Object.assign(err, { status: 502 });
    }

Observed Behavior

This error is thrown:

{
  "name": "304",
  "$fault": "client",
  "$metadata": {
    "httpStatusCode": 304,
    "requestId": "txf0dab84e1901420c995fe-0065e8c28e",
    "extendedRequestId": "txf0dab84e1901420c995fe-0065e8c28e",
    "attempts": 1,
    "totalRetryDelay": 0
  },
  "message": "UnknownError"
}

Expected Behavior

An error with name "NotModified"

Possible Solution

double-check there is code to handle an HTTP status of 304

Additional Information/Context

I confess I have only run this against min.io and OpenIO - i assumed AWS S3 would work. I'm scheduled to test against AWS S3 soon.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue is a bug.p2This is a standard priority issuequeuedThis issues is on the AWS team's backlog

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions