aws-sdk-js-v3 icon indicating copy to clipboard operation
aws-sdk-js-v3 copied to clipboard

S3 ListObjectVersions ObjectVersionStorageClass type is incorrect

Open rawpixel-vincent opened this issue 1 year ago • 9 comments

Checkboxes for prior research

Describe the bug

the type of ObjectVersionStorageClass in the result output of ListObjectVersionsOutput.Versions[].StorageClass is allowing only "STANDARD", it should allow all possible storage class.

Screenshot 2024-02-27 at 13 06 36 Screenshot 2024-02-27 at 13 09 20 Screenshot 2024-02-27 at 13 09 11

SDK version number

@aws-sdk/[email protected]

Which JavaScript Runtime is this issue in?

Node.js

Details of the browser/Node.js/ReactNative version

v20.11.0

Reproduction Steps

Request ListObjectVersionsCommand

example:

    const VS = await s3ClientApSoutheast1.send(
      new ListObjectVersionsCommand({
        Bucket: 'bucket-name',
      }),
    );

Observed Behavior

Versions[].StorageClass type is fixed to "STANDARD"

Expected Behavior

Versions[].StorageClass type should allow any valid storage class

Possible Solution

No response

Additional Information/Context

No response

rawpixel-vincent avatar Feb 27 '24 06:02 rawpixel-vincent

According to this service documentation, I only see STANDARD available: https://docs.aws.amazon.com/AmazonS3/latest/API/API_ObjectVersion.html.

If DEEP_ARCHIVE is indeed available, we have to wait for the service to push the model update to the SDKs.

kuhe avatar Feb 27 '24 16:02 kuhe

Ahh I see that's a bug in the services documentation, what are the steps to move this there?

rawpixel-vincent avatar Feb 27 '24 20:02 rawpixel-vincent

Hi @rawpixel-vincent - you can directly reach out to service team via AWS Support or we can submit a request to service team on your behalf. Let us know if you'd like us to submit a request.

aBurmeseDev avatar Feb 27 '24 20:02 aBurmeseDev

Hi, it's great if you don't mind forwarding this request on my behalf. Thank you

rawpixel-vincent avatar Feb 27 '24 20:02 rawpixel-vincent

Submitted a request to service team, and transferred the issue to our cross-SDK repo, please check back in for updates. (ref:P120170678)

aBurmeseDev avatar Feb 27 '24 22:02 aBurmeseDev

Hi, it's been a while, just hit the same issue today, any chances to get this resolved ?

rawpixel-vincent avatar Aug 20 '25 11:08 rawpixel-vincent

confirmed again all storage class can be seen.

  let classViewed = new Set();
  while (true) {
    const VS = await s3Client.send(
      new ListObjectVersionsCommand({
        Prefix: prefix,
        Bucket: '*****',
        MaxKeys: 1000,
        KeyMarker: nextKeyMarker,
      }),
    );

    if (!VS?.Versions?.length) {
      break;
    }
    nextKeyMarker = VS.IsTruncated ? VS.NextKeyMarker : null;
    for (const v of VS.Versions) {
      if (!classViewed.has(v.StorageClass)) {
        console.log(
          `Class:${v.StorageClass}, Version:${v.VersionId}, Key:${v.Key}`,
        );
        classViewed.add(v.StorageClass);
      }
      if (classViewed.size > 2) {
        return;
      }
}
Class:STANDARD, Version:nhvqjDv__1qS*****FhjxZje70, Key:**2*-**/rm*6*-***dboa*de*-0**zip
Class:STANDARD_IA, Version:9y33U******FpITV17E6pL, Key:2*22-****m558*e**m*n*-r**r*computer*m**kup**ip
Class:INTELLIGENT_TIERING, Version:****UBd, Key:2*2*-12/p*20*2***60-***m*02**-0*-*ob1*6**v-**.e*s

rawpixel-vincent avatar Aug 20 '25 12:08 rawpixel-vincent

Workaround

/**
 * @typedef {Omit<import('@aws-sdk/client-s3').ListObjectVersionsOutput, 'Versions'> & {Versions: (Omit<import('@aws-sdk/client-s3').ObjectVersion, 'StorageClass'> & {StorageClass: import('@aws-sdk/client-s3').StorageClass})[]}} ListObjectVersionsOutputWithStorageClass
 */
    const VS = /** @type {ListObjectVersionsOutputWithStorageClass} */ (
      await s3Client.send(
        new ListObjectVersionsCommand({
          Prefix: prefix,
          Bucket: bucket,
          MaxKeys: 1000,
          KeyMarker: nextKeyMarker,
        }),
      )
    );

rawpixel-vincent avatar Aug 20 '25 12:08 rawpixel-vincent

No updates from service team, so far. I had just checked in for updates.

aBurmeseDev avatar Sep 24 '25 07:09 aBurmeseDev