aws-sdk-go-v2 icon indicating copy to clipboard operation
aws-sdk-go-v2 copied to clipboard

service/s3/types.ObjectVersionStorageClass enum should cover all possible values this field may have

Open nightmarlin-wise opened this issue 6 months ago • 0 comments

Acknowledgements

  • [x] I have searched (https://github.com/aws/aws-sdk/issues?q=is%3Aissue) for past instances of this issue
  • [x] I have verified all of my SDK modules are up-to-date (you can perform a bulk update with go get -u github.com/aws/aws-sdk-go-v2/...)

Describe the bug

The enum types.ObjectVersionStorageClass (https://github.com/aws/aws-sdk-go-v2/blob/main/service/s3/types/enums.go#L968-L973) only declares one value:

// Enum values for ObjectVersionStorageClass
const (
	ObjectVersionStorageClassStandard ObjectVersionStorageClass = "STANDARD"
)

But instances of this type may have different values - EG when calling ListObjectVersions, ListObjectVersionsOutput.Versions[*].StorageClass may have the value GLACIER_IR (see attached image)

Image

Regression Issue

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

Expected Behavior

All possible values of service/s3/types.ObjectVersionStorageClass should be defined in the package.

Current Behavior

Only the STANDARD ObjectVersionStorageClass is defined.

Reproduction Steps

import (
	"context"
	"fmt"
	"strings"

	"github.com/aws/aws-sdk-go-v2/aws"
	"github.com/aws/aws-sdk-go-v2/config"
	"github.com/aws/aws-sdk-go-v2/service/s3"
	"github.com/aws/aws-sdk-go-v2/service/s3/types"
)

var (
	bucketName   = "my-bucket"
	bucketRegion = "my-bucket-region"
	objectName   = "my-object.txt"
	inputReader  = strings.NewReader("arbitrary text")

	// [types.ObjectVersionStorageClass.Values] is static.
	knownObjectVersionStorageClasses = types.ObjectVersionStorageClass.Values("")
)

func main() {
	ctx := context.Background()
	cfg, _ := config.LoadDefaultConfig(ctx, config.WithRegion(bucketRegion))
	s3c := s3.NewFromConfig(cfg)

	_, _ := s3c.PutObject(
		ctx,
		&s3.PutObjectInput{
			Bucket:       aws.String(bucketName),
			Key:          aws.String(objectName),
			Body:         inputReader,
			StorageClass: types.StorageClassGlacierIr,
		},
	)

	list, _ := s3c.ListObjectVersions(
		ctx,
		&s3.ListObjectVersionsInput{Bucket: aws.String(bucketName)},
	)

	for _, v := range list.Versions {
		if !slices.Contains(knownObjectVersionStorageClasses, v.StorageClass) {
			fmt.Printf("object %q has undefined storage class %q\n", *v.Key, v.StorageClass)
		}
	}
}

outputs:

object "my-object.txt" has undefined storage class "GLACIER_IR"

Possible Solution

As this file is generated, it's possible that an upstream definition is missing / not being read. I would expect this set of values to match the possible values of ObjectStorageClass (link).

Additional Information/Context

This can be worked around by casting values of this type to types such as ObjectStorageClass - but as they are different enums it is possible for these to diverge.

AWS Go SDK V2 Module Versions Used

github.com/aws/aws-sdk-go-v2 v1.36.3
github.com/aws/aws-sdk-go-v2/config v1.29.14
github.com/aws/aws-sdk-go-v2/service/s3 v1.80.0

Compiler and Version used

go version go1.24.3 darwin/arm64

Operating System and version

MacOS Sequoia 15.5

nightmarlin-wise avatar Jun 05 '25 14:06 nightmarlin-wise