Skip to content

fix(pagination): silent pagination truncation when native API uses PageSize or StartingToken#10443

Open
Abuhaithem wants to merge 1 commit into
aws:developfrom
Abuhaithem:fix/pagination-silent-truncation
Open

fix(pagination): silent pagination truncation when native API uses PageSize or StartingToken#10443
Abuhaithem wants to merge 1 commit into
aws:developfrom
Abuhaithem:fix/pagination-silent-truncation

Conversation

@Abuhaithem

Copy link
Copy Markdown

Fixes #10442

This pull request fixes a critical bug where providing the global pagination parameters --page-size or --starting-token silently disabled automatic pagination for a subset of AWS API commands, resulting in silent data truncation (returning only the first page and exiting with code 0).

Motivation and Context

The AWS CLI supports automatic pagination by injecting global parameters (--page-size, --starting-token, --max-items) and intentionally disabling automatic pagination if the user specifies a raw, native API pagination parameter (e.g., --next-token or --marker).

The logic checking for this collision in awscli.customizations.paginate.check_should_enable_pagination had a typographical error (start_token instead of starting_token) and completely omitted page_size:

normalized_paging_args = ['start_token', 'max_items']

As a result, if an API operation naturally defines its limit_key as exactly "PageSize" (rather than "MaxResults" or "MaxItems"), the raw API argument name shadows the global CLI argument. Because page_size was missing from normalized_paging_args, the CLI assumed the user was intentionally specifying the undocumented raw API parameter and disabled automatic pagination.

This silently broke automated pagination for over 50 operations across elb, elbv2, servicecatalog, pinpoint-email, mailmanager, sesv2, ce, and lakeformation (whenever --page-size was explicitly specified), as well as ssm-quicksetup (when --starting-token was specified).

This fix corrects the tuple to properly exempt the global parameters from disabling pagination:

normalized_paging_args = ['starting_token', 'page_size', 'max_items']

Testing Done

Validated via aws elbv2 describe-load-balancers --page-size 10, confirming that the CLI now automatically paginates and fetches all load balancers instead of aborting after the first 10 items.
Added a direct mock validation simulating the parser flow, verifying parsed_globals.paginate remains True.

Types of Changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

…global CLI paging arguments

Corrects a typo ( -> ) and an omission () in the  allowlist within .

Previously, if an API operation naturally defined its paginator limit key as exactly PageSize (e.g., ), the global  argument was incorrectly identified as an undocumented manual API parameter. This caused the CLI to silently disable automatic pagination and prematurely truncate results after fetching a single page. This fix restores the correct behavior, ensuring global paging parameters do not unintentionally disable automatic pagination.
@Abuhaithem Abuhaithem requested a review from a team as a code owner June 26, 2026 23:54
@Abuhaithem

Copy link
Copy Markdown
Author

@kdaily could u check this PR ?

@Abuhaithem

Copy link
Copy Markdown
Author

@ashovlin could u check this PR

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Silent Pagination Truncation when using --page-size or --starting-token on affected services

1 participant