smithy-lang / smithy

Smithy is a protocol-agnostic interface definition language and set of tools for generating clients, servers, and documentation for any programming language.
https://smithy.io
Apache License 2.0
1.76k stars 206 forks source link

Paginated trait doesn't support pagination scheme with a moreResults boolean #604

Closed adam-fowler closed 3 years ago

adam-fowler commented 3 years ago

A number of paginated AWS operations indicate there are more results via a boolean and not whether an "outputToken" is returned. See https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListParts.html where the existence of more results is indicated via a IsTruncated value in the response.

The paginated trait does not provide support for this.

mtdowling commented 3 years ago

I'm not aware of any API where the IsTruncated style parameter is necessary for pagination. If there aren't more results, the NextToken/NextMarker/etc member on output is supposed to be omitted. There are some other things that SDKs do as well to account for tail-style APIs, for example if they get the same token twice in a row they stop paginating.

adam-fowler commented 3 years ago

The API I mention above S3.ListParts does exactly that. It will return a nextToken when there are no more results but also returns isTruncated set to false.

I guess checking for the same token being returned twice might be a solution in this case. I would have to verify that for S3.ListParts.

adam-fowler commented 3 years ago

Actually S3.ListParts pagination is not available in the Smithy files in the aws-sdk-go-v2 repo but it is available in the old style json models. I know this doesn't necessarily mean anything but thought it was worth noting.

mtdowling commented 3 years ago

Because moreResults is no longer needed for pagination, I'll go ahead and resolve this issue.

adam-fowler commented 3 years ago

I had a look at using the same token in a row method for S3.ListMultipartUploads and it doesn't work. It just resets to the beginning of the list again.

I don't think this is resolved.

EDIT: Wrong method, I meant S3.ListParts()

adam-fowler commented 3 years ago

@mtdowling See https://github.com/aws/aws-sdk-go-v2/pull/1141