Skip to content

fix: resolve --query corrupting pagination resume token in text output and --page-size/--starting-token silently disabling auto-pagination#10455

Open
Hardikrepo wants to merge 1 commit into
aws:developfrom
Hardikrepo:develop
Open

fix: resolve --query corrupting pagination resume token in text output and --page-size/--starting-token silently disabling auto-pagination#10455
Hardikrepo wants to merge 1 commit into
aws:developfrom
Hardikrepo:develop

Conversation

@Hardikrepo

Copy link
Copy Markdown

Summary

  • Fix Bug Report: aws --output text with --query prints a spurious None line for the pagination resume-token hint #10449aws --output text with --query was printing a spurious None line when a paginated response was truncated. The TextFormatter was passing the pagination resume-token hint {'NextToken': {'NextToken': <token>}} through _format_response(), which applied the user's --query JMESPath expression to it. Any data query (e.g. Users[].UserName) evaluates to None against that metadata dict and the literal string None was written to stdout, silently corrupting script output.

  • Fix Silent Pagination Truncation when using --page-size or --starting-token on affected services #10442 — Using --page-size against APIs whose native limit_key is named PageSize (e.g. aws elbv2 describe-load-balancers), or --starting-token against APIs whose native input_token is named StartingToken (e.g. aws ssm-quicksetup list-configurations), silently disabled automatic pagination and returned only the first page with exit code 0. The root cause was that check_should_enable_pagination() only had ['start_token', 'max_items'] in normalized_paging_args, so page_size and starting_token were misidentified as user-specified native API args, triggering --no-paginate.

Changes

awscli/formatter.py

  • In TextFormatter.__call__, write the resume-token hint directly via text.format_text() instead of routing it through _format_response(), so the --query filter is never applied to pagination metadata.

awscli/customizations/paginate.py

  • Added page_size and starting_token to normalized_paging_args in check_should_enable_pagination() so the unified CLI pagination args are never mistaken for native API pagination params.

Test plan

  • aws iam list-users --max-items 1 --output text --query 'Users[].UserName' — confirm no None line appears after the username, and NEXTTOKEN line is still printed
  • aws elbv2 describe-load-balancers --page-size 5 — confirm all load balancers are returned (not just first page)
  • aws ssm-quicksetup list-configurations --starting-token <token> — confirm pagination resumes correctly and auto-pagination is not disabled
  • Existing pagination unit tests pass

@Hardikrepo Hardikrepo requested a review from a team as a code owner June 29, 2026 17:53
…nd --page-size/--starting-token silently disabling auto-pagination (aws#10442)

- formatter.py: write NextToken hint via text.format_text() directly,
  bypassing _format_response() so --query is never applied to pagination
  metadata
- paginate.py: add page_size and starting_token to normalized_paging_args
  so unified CLI args are not mistaken for native API pagination params
- tests: unit tests for both fixes covering the exact regression scenarios
@Abuhaithem

Abuhaithem commented Jul 1, 2026

Copy link
Copy Markdown

I've already opened a PR for this issues (#10442 , #10449) before you opened yours.

You can find it here: #10443, #10450.

Could you please close your PR?

Also, for future contributions, please check whether an issue has already been claimed or already has an open PR before creating a new one. Additionally, please avoid combining fixes for multiple issues into a single PR—it's better to keep one PR per issue. Thanks!

@Hardikrepo

Copy link
Copy Markdown
Author

Thanks for flagging! I checked #10443 and #10450 — both are still open/unmerged, and #10449 and #10442 are actually assigned to a maintainer (@RyanFitzSimmonsAK), not claimed by either of us. Since there's no merged fix yet, I'll leave this PR open for maintainer review and keep it as a single combined PR rather than splitting it, since both fixes touch closely related pagination-metadata handling. Happy to split if a maintainer prefers that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants