Skip to content

Kinesis: honour NextToken/MaxResults in list_stream_consumers - #10161

Open
UTKARSH698 wants to merge 1 commit into
getmoto:masterfrom
UTKARSH698:fix/kinesis-list-stream-consumers-pagination
Open

Kinesis: honour NextToken/MaxResults in list_stream_consumers#10161
UTKARSH698 wants to merge 1 commit into
getmoto:masterfrom
UTKARSH698:fix/kinesis-list-stream-consumers-pagination

Conversation

@UTKARSH698

Copy link
Copy Markdown
Contributor

Problem

ListStreamConsumers declares NextToken and MaxResults as input members and NextToken as an output member:

ListStreamConsumers IN : ['StreamARN', 'NextToken', 'MaxResults', 'StreamCreationTimestamp']
                   OUT: ['Consumers', 'NextToken']

moto read neither input parameter and never emitted NextToken -- list_stream_consumers returned every consumer in a single response and carried a Pagination is not yet implemented docstring. Clients that page explicitly either loop forever on an unchanging token or silently receive the full list when they asked for a bounded page.

Fix

Wires the operation through the module's existing @paginate(PAGINATION_MODEL) helper, exactly as list_shards already does in the same files:

  • moto/kinesis/utils.py -- new PAGINATION_MODEL entry, unique_attribute is consumer_arn (already unique per consumer)
  • moto/kinesis/models.py -- @paginate decorator, and the now-inaccurate docstring removed
  • moto/kinesis/responses.py -- reads NextToken/MaxResults and returns the token

limit_default is 10000, matching both list_shards and the botocore MaxResults max, so a caller that passes no MaxResults gets the same full list as before -- no behaviour change for existing users.

Verification

Against a real boto3 client, 5 consumers at MaxResults=2:

page1: ['c0', 'c1'] | NextToken present
page2: ['c2', 'c3'] | NextToken present
page3: ['c4']       | NextToken absent
no-args (back-compat): ['c0','c1','c2','c3','c4']
botocore paginator:    ['c0','c1','c2','c3','c4']

The last page correctly omits NextToken (moto emits null and botocore drops JSON nulls), so botocore's own paginator terminates.

Test added to the existing tests/test_kinesis/test_kinesis_stream_consumers.py, including the no-MaxResults back-compat assertion. tests/test_kinesis/: 81 passed; the 4 failures are pre-existing openapi_spec_validator import errors in test_kinesis_cloudformation.py, unrelated to this change. ruff check, ruff format --check and mypy moto/kinesis/ all clean. The docs/ stanza is updated to match the removed docstring.

ListStreamConsumers declares NextToken/MaxResults as input and NextToken
as output, but moto read neither and returned every consumer in a single
response, so paginating clients looped or silently saw a full list.

Wire it through the module's existing @paginate helper, the same way
list_shards already does.
@codecov

codecov Bot commented Aug 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.24%. Comparing base (9fcefb7) to head (e1f206c).

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #10161      +/-   ##
==========================================
- Coverage   93.24%   93.24%   -0.01%     
==========================================
  Files        1326     1326              
  Lines      121003   121006       +3     
==========================================
  Hits       112832   112832              
- Misses       8171     8174       +3     
Flag Coverage Δ
servertests 27.96% <20.00%> (+<0.01%) ⬆️
unittests 93.22% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

1 participant