Conversation
The generated PaginationConfig docs told readers that exceeding MaxItems puts a NextToken "in the output". The pages yielded by the iterator never carry that token: PageIterator only records a resume token on itself, and only build_full_result() copies it out under the NextToken key. Following the documented behaviour on a page raises KeyError, as reported in boto/boto3#3677. Describe where the token actually appears, and note that the tokens present on individual pages come from the service and track PageSize rather than MaxItems.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is wrong
The generated
PaginationConfigdocs describeMaxItemslike this:The pages yielded by the iterator never carry that token.
PageIteratorrecords a resume token on itself (_truncate_response→self.resume_token, and the page-boundary branch in__iter__), and onlybuild_full_result()copies it out under aNextTokenkey. A page dict contains whatever pagination token the service returned, and the service only returns one when it was asked for a partial page — whichPaginationConfigcontrols viaPageSize(the paginator'slimit_key), not viaMaxItems.MaxItemsis applied client-side after the response arrives and is never sent to the service.So a reader who follows the sentence above and indexes the token on a page gets a
KeyError. That is what boto/boto3#3677 reports.Reproduction
The issue's repro needs S3 credentials, so here is the same thing against a stub, using botocore's own
Paginatoron this branch's parent commit. The fake service holds 10 items and returns aNextTokenonly when it has more to give:Output:
The first block is the documented condition — 10 items available,
MaxItems=4— and there is noNextTokenon the page. The second block shows the inverse:PageSizealone puts tokens on pages but leavesbuild_full_result()without one, because pagination ran to completion.The change
One
DocumentedShapedocumentation string inbotocore/docs/paginator.py. Rendered result:Judgement calls, and where I would welcome a different answer
MaxItemsstring, because that is the sentence the issue quotes and links by line. I deliberately left two adjacent things alone: thePageSizestring ("The size of each page."), which says nothing about it being the thing that drives server-side paging and token emission, and theNextTokenentry inbotocore_pagination_response_params, which renders under Response Syntax and so still reads as if every page carried the token. Both arguably belong in the same cleanup. I kept them out to keep this reviewable; say the word and I will fold them in, or open them separately. ThePageSizeconstraint gap that @RyanFitzSimmonsAK raised is RDS describe_db_instances paginator has incorrect PaginationConfig description boto3#3798 and is untouched here.build_full_result()andresume_tokenin per-service generated docs is more API detail than the surrounding text usually carries. The alternative is a vaguer "the token is not returned on individual pages" without saying where it is, which I thought less useful. Happy to trim if you prefer the shorter form.What I verified, and what I did not
python -m pytest tests/unit/docs tests/unit/test_paginate.py -q→323 passedon this branch, and323 passedon the same commit without the change. The existing assertion intests/unit/docs/test_paginator.pymatches the- **MaxItems** *(integer) --*header line only, not the body text, so it is unaffected.tests/unit/docs' own harness to confirm the reST output above.tests/functional/docs. It renders documentation for every service and I had to abandon it on a disk-constrained machine, so CI should be the judge there. Everything above is macOS arm64, Python 3.14, againste2b579b.Refs boto/boto3#3677.
Generated by AI tools, and reviewed by hxperl.