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

Add paging API that errors if you don't check NextToken #3674

Closed
kevinburke1 opened this issue Dec 4, 2020 · 2 comments
Closed

Add paging API that errors if you don't check NextToken #3674

kevinburke1 opened this issue Dec 4, 2020 · 2 comments
Labels
feature-request A feature should be added or improved.

Comments

@kevinburke1
Copy link

kevinburke1 commented Dec 4, 2020

Hi,
We just had a production incident in part because we retrieved the first page of a list, assumed there were no more pages and ended up returning a subset of the available resources. That's an easy mistake to make based on the design, which returns you the results and the NextToken side by side, e.g.

type ListFunctionDefinitionVersionsOutput struct {
    NextToken *string `type:"string"`

    Versions []*VersionInformation `type:"list"`
    // contains filtered or unexported fields
}

It would be nice if there was a pagination design that made it harder to skip past the second, third, fourth page of resources. For example, borrow from the rows.Next() implementation in database/sql or bufio.Scanner. Or here is how I roughly implemented this in my twilio-go library.

iterator := greengrass.GetListFunctionDefinitionVersionIterator(url.Values{})
for {
    page, err := iterator.Next(context.TODO())
    if err == aws.NoMoreResults {
        break
    }
    fmt.Println("versions", page.Versions)
}

It's a lot harder to accidentally forget to page that way.

@kevinburke1 kevinburke1 added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Dec 4, 2020
@kevinburke1
Copy link
Author

Ah, I think it looks like the V2 api has given this considerable thought, gonna close. aws/aws-sdk-go-v2#439

@github-actions
Copy link

github-actions bot commented Dec 7, 2020

⚠️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.

@vudh1 vudh1 removed the needs-triage This issue or PR still needs to be triaged. label Jul 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request A feature should be added or improved.
Projects
None yet
Development

No branches or pull requests

2 participants