Skip to content

fix: paginate all SCA list endpoints via nextToken - #38

Merged
aaearon merged 2 commits into
aaearon:mainfrom
svnlto:fix/pagination
Apr 6, 2026
Merged

fix: paginate all SCA list endpoints via nextToken#38
aaearon merged 2 commits into
aaearon:mainfrom
svnlto:fix/pagination

Conversation

@svnlto

@svnlto svnlto commented Mar 31, 2026

Copy link
Copy Markdown
Contributor

Summary

  • ListEligibility, ListSessions, and ListGroupsEligibility only fetched the first page of results — users with >10 targets/sessions/groups saw silently truncated data
  • All three methods now loop on nextToken, accumulating results across pages
  • Added maxPages (100) guard to prevent infinite loops if the API misbehaves
  • Fixed pre-existing time-sensitive test in session_tracker_test.go

Test plan

  • Added pagination tests for all three endpoints verifying multi-page accumulation
  • Tests assert nextToken is forwarded as a query parameter on subsequent calls
  • Existing tests pass (go test ./...)

svnlto and others added 2 commits April 6, 2026 08:08
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
@aaearon
aaearon merged commit cece004 into aaearon:main Apr 6, 2026
1 check passed
@aaearon

aaearon commented Apr 6, 2026

Copy link
Copy Markdown
Owner

thanks for contributing!

@svnlto

svnlto commented Apr 8, 2026

Copy link
Copy Markdown
Contributor Author

@aaearon can you cut a new release with these change, please?

@svnlto
svnlto deleted the fix/pagination branch April 8, 2026 16:13
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.

2 participants