aws / aws-sdk-go

AWS SDK for the Go programming language.
http://aws.amazon.com/sdk-for-go/
Apache License 2.0
8.63k stars 2.07k forks source link

`ListTagsForResourceOutput.NextMarker` with empty string #3513

Closed anton-yurchenko closed 3 years ago

anton-yurchenko commented 4 years ago

Confirm by changing [ ] to [x] below to ensure that it's a bug:

Describe the bug ListTagsForResource return NextMarker as empty string instead of nil.

I have a single CloudFront WAF IP Set which I am trying to retrieve with ListTagsForResource and I expect NextMarker to return nil as described here but instead it returns as empty string and causes the following error on next iteration:

InvalidParameter: 1 validation error(s) found.
- minimum field size of 1, ListTagsForResourceInput.NextMarker.

P.S: just in case this may collide somehow, I have some IP match conditions on "classic" (v1) WAF

Version of AWS SDK for Go?

1.34.13

Version of Go (go version)?

go version go1.14.2 darwin/amd64

To Reproduce (observed behavior)

package main

import (
    "fmt"
    "os"

    "github.com/aws/aws-sdk-go/aws"
    "github.com/aws/aws-sdk-go/aws/session"
    "github.com/aws/aws-sdk-go/service/wafv2"
)

func main() {
    s := session.Must(session.NewSession())
    cli := wafv2.New(s)

    var token *string
    for {
        o, err := cli.ListTagsForResource(&wafv2.ListTagsForResourceInput{
            Limit:       aws.Int64(1),
            ResourceARN: aws.String("arn:aws:wafv2:us-east-1:<account-id>:global/ipset/<ipset-name>/<ipset-id>"),
            NextMarker:  token,
        })
        if err != nil {
            fmt.Println(err)
            os.Exit(1)
        }

        if o.NextMarker != nil {
            token = o.NextMarker
            fmt.Printf("-> next marker: '%v'\n", *o.NextMarker)
        } else {
            break
        }
    }
}
-> next marker: ''
InvalidParameter: 1 validation error(s) found.
- minimum field size of 1, ListTagsForResourceInput.NextMarker.

exit status 1

Expected behavior NextMarker should be returned only if there are more resources to retrieve, otherwise nil.

Quote from docs:

When you request a list of objects with a Limit setting, if the number of objects that are still available for retrieval exceeds the limit, AWS WAF returns a NextMarker value in the response.

skotambkar commented 3 years ago

We do not have plans to fix this in V1 SDK. The aws/aws-sdk-go-v2 has fixed this issue.

github-actions[bot] commented 3 years ago

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.