Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

S3 missing an error type for NoSuchTagSet #675

Open
taylor-sutton opened this issue Jan 2, 2024 · 3 comments
Open

S3 missing an error type for NoSuchTagSet #675

taylor-sutton opened this issue Jan 2, 2024 · 3 comments
Assignees
Labels
bug Something isn't working s3 service-api This issue pertains to the AWS API

Comments

@taylor-sutton
Copy link

Describe the bug

As per https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketTagging.html - the GetBucketTagging operation can return with a code NoSuchTagSet. However in s3 types, there is no corresponding error type.

Expected Behavior

I am able to refer to a types.NoSuchTagSet to type-safely check for this error.

Current Behavior

I get the following:

operation error S3: GetBucketTagging, https response error StatusCode: 404, RequestID: 1TQC5RB7RETDG6W9, HostID: 4seX6a1w9R//EtPng9skN/1cjcXuiBTsJ3IHxd0abABvoThEYi2wrC4KgAudD0VBM7AUPE4fFTw=, api error NoSuchTagSet: The TagSet does not exist

when showing the error via fmt.Printf("%+v\n", err)

Reproduction Steps

I am not sure the best way to create an S3 bucket that doesn't have any associated tag set, as opposed to having an empty tag set associated. In my case I see this for the bucket amazon-connect-1cc70ca065cd:

package main

import (
	"context"
	"fmt"

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


func main() {
	ctx := context.Background()

	cfg, err := config.LoadDefaultConfig(ctx, config.WithRegion("us-west-2"))
	if err != nil {
		log.Fatalf("unable to load SDK config, %v", err)
	}

	client := s3.NewFromConfig(cfg)
	_, err = client.GetBucketTagging(ctx, &s3.GetBucketTaggingInput{
		Bucket: aws.String("amazon-connect-1cc70ca065cd"),
	})
	fmt.Printf("%+T; %+v\n", err, err)
}

Output:

*smithy.OperationError; operation error S3: GetBucketTagging, https response error StatusCode: 404, RequestID: BWJ5NJSVYNKETRXY, HostID: KZ6OuFYuikM5s/GvQnMFLYEv0cby+Tge7NowednJHnOkNdJa47WNTp3eKDjBYCDxZtGo3t/HCM9d4RdNIZ8LSQ==, api error NoSuchTagSet: The TagSet does not exist

Possible Solution

No response

Additional Information/Context

No response

AWS Go SDK V2 Module Versions Used

Complete go.mod:

module s3_dr

go 1.21

require (
	github.com/aws/aws-sdk-go v1.49.13
	github.com/aws/aws-sdk-go-v2/config v1.26.2
	github.com/aws/aws-sdk-go-v2/service/s3 v1.47.7
)

require (
	github.com/aws/aws-sdk-go-v2 v1.24.0 // indirect
	github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.5.4 // indirect
	github.com/aws/aws-sdk-go-v2/credentials v1.16.13 // indirect
	github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.14.10 // indirect
	github.com/aws/aws-sdk-go-v2/internal/configsources v1.2.9 // indirect
	github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.5.9 // indirect
	github.com/aws/aws-sdk-go-v2/internal/ini v1.7.2 // indirect
	github.com/aws/aws-sdk-go-v2/internal/v4a v1.2.9 // indirect
	github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.10.4 // indirect
	github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.2.9 // indirect
	github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.10.9 // indirect
	github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.16.9 // indirect
	github.com/aws/aws-sdk-go-v2/service/sso v1.18.5 // indirect
	github.com/aws/aws-sdk-go-v2/service/ssooidc v1.21.5 // indirect
	github.com/aws/aws-sdk-go-v2/service/sts v1.26.6 // indirect
	github.com/aws/smithy-go v1.19.0 // indirect
)

Compiler and Version used

go version go1.21.3 darwin/arm64

Operating System and version

macOS 14.2.1

@taylor-sutton taylor-sutton added bug Something isn't working needs-triage labels Jan 2, 2024
@RanVaknin
Copy link

Hi @taylor-sutton ,

Thanks for reaching out. If you did not know, all of the AWS SDKs are code generated from the API models of each AWS service. In this case, S3 did not specify this as an error type in their model as you can see here (linking v1 model since v2 model is in raw format):

    "GetBucketTagging":{
      "name":"GetBucketTagging",
      "http":{
        "method":"GET",
        "requestUri":"/{Bucket}?tagging"
      },
      "input":{"shape":"GetBucketTaggingRequest"},
      "output":{"shape":"GetBucketTaggingOutput"},
      "documentationUrl":"http://docs.amazonwebservices.com/AmazonS3/latest/API/RESTBucketGETtagging.html",
      "staticContextParams":{
        "UseS3ExpressControlEndpoint":{"value":true}
      }
    },

As seen in this operation definition, this is missing an errors array containing all the possible errors an operation can return.

Here is an example of how a modeled error should look like:

    "HeadBucket":{
      "name":"HeadBucket",
      "http":{
        "method":"HEAD",
        "requestUri":"/{Bucket}"
      },
      "input":{"shape":"HeadBucketRequest"},
      "output":{"shape":"HeadBucketOutput"},
      "errors":[
        {"shape":"NoSuchBucket"}
      ],
      "documentationUrl":"http://docs.amazonwebservices.com/AmazonS3/latest/API/RESTBucketHEAD.html"
    },

Since the S3 team did not specify this as an error type in their API, the SDK will not generate a concrete type for it, and there is nothing we can do on the SDK side to introduce this without a model change. Here is a related issue on the JS SDK basically referring to the same problem with headBucket not modeling other errors.
The S3 team is slow to introduce changes to their API model, so they supplement it by adding relevant documentation as seen in the doc string you linked.

Error code: NoSuchTagSet

Description: There is no tag set associated with the bucket.

So you could get around this by simply doing string comparison which should be safe.

	if err != nil {
		if strings.Contains(err.Error(), "NoSuchTagSet") {
			fmt.Println("NoSuchTagSet error occurred")
		}
	}

Thanks,
Ran~

@RanVaknin RanVaknin self-assigned this Jan 4, 2024
@RanVaknin RanVaknin added response-requested This issue requires a response to continue and removed needs-triage labels Jan 4, 2024
@taylor-sutton
Copy link
Author

Hi @RanVaknin , thanks for your response. Is there an appropriate place I can nudge (or add to an existing nudge) the S3 team to update their data model?

Since it sounds like there is nothing on the SDK side, feel free to close this issue.

@github-actions github-actions bot removed the response-requested This issue requires a response to continue label Jan 5, 2024
@RanVaknin
Copy link

Hi @taylor-sutton ,
Thanks for your patience.

I have created another internal ticket with the S3 team with very detailed instructions on what needs to change on their backend to make it as easy of a change as possible.

I just want to set your expectation that S3 is an enormous team both in terms of the size of the organization and the amount of work they handle, so it might take a while until this ticket makes it to the right person, and until it gets prioritzied.
One thing you can do is create your own internal ticket via the AWS developer console and refer to the ticket I have created P112680375. This should help push this in the right direction.

Transferring to the cross-sdk repo for further tracking.

Thanks again,
Ran~

@RanVaknin RanVaknin transferred this issue from aws/aws-sdk-go-v2 Jan 10, 2024
@RanVaknin RanVaknin added service-api This issue pertains to the AWS API s3 labels Jan 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working s3 service-api This issue pertains to the AWS API
Projects
None yet
Development

No branches or pull requests

2 participants