fix: paginate all SCA list endpoints via nextToken - #38
Merged
Conversation
ListEligibility, ListSessions, and ListGroupsEligibility only fetched the first page of results. The API paginates at 50 items with nextToken continuation, so users with >50 targets/sessions/groups saw truncated data silently. All three methods now loop on nextToken, accumulating results across pages. A maxPages guard (100) prevents infinite loops if the API misbehaves.
- Extract paginate[T] generic helper to DRY up the three copy-pasted pagination loops in ListEligibility, ListSessions, and ListGroupsEligibility - Capture Total from the first page instead of the last page - Remove unrealistic TestListEligibility_WithPagination (empty final page); TestListEligibility_Pagination already covers two-page scenario - Add TestListEligibility_PaginationMaxPagesExceeded to verify the maxPages safety cap returns an error - Add TestListEligibility_Pagination_TotalFromFirstPage to verify Total is taken from page 1 - Revert unrelated session_tracker_test.go change (belongs in PR aaearon#37); pin Store clock in test for deterministic behavior
Owner
|
thanks for contributing! |
Contributor
Author
|
@aaearon can you cut a new release with these change, please? |
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.
Summary
ListEligibility,ListSessions, andListGroupsEligibilityonly fetched the first page of results — users with >10 targets/sessions/groups saw silently truncated datanextToken, accumulating results across pagesmaxPages(100) guard to prevent infinite loops if the API misbehavessession_tracker_test.goTest plan
nextTokenis forwarded as a query parameter on subsequent callsgo test ./...)