Skip to content

Fail --paginate on a list it cannot read to its end - #23

Open
edumansky wants to merge 1 commit into
mainfrom
paginate-fail-closed
Open

edumansky wants to merge 1 commit into
mainfrom
paginate-fail-closed

Conversation

@edumansky

@edumansky edumansky commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

--paginate could return part of a list as if it were the whole list. Two problems:

1. It stopped early without saying so (paginateOffset, used for Admin, Calling, Messaging, Meetings, Devices and SCIM lists):

  • SCIM page cap: a SCIM list whose server returned fewer items per page than asked for ended after the first page, although totalResults said there was more.
  • Repeated page: an endpoint that ignored the paging parameters and returned the same page again ended the list without an error.
  • Next page on another host: the token is still never sent there. But the list ended without an error on a later page, or fell back to offsets on the first.

2. Contact Center lists with no page metadata were read as one page (visitCC):

  • Plain arrays: a plain-array response, as the flow store and functions return without includePagination, was always taken as the only page. A list longer than 100 lost everything after its first 100 items.
  • {data} without metadata: the same happened to a {data} response with no meta or pageInfo.

What changes

  • SCIM: lists are read until totalResults is reached. If the list ends before its total, the command fails.
  • No page metadata: a full page (100 items) of a plain array, or of {data}, now leads to another request; a shorter page ends the list.
  • Failures: a repeated page, a SCIM list that ends before its total, and a next page on another host now fail with incomplete list instead of returning what was read so far.
  • Repeat that is still fine: a page longer than the 100 asked for shows the endpoint ignored the size and sent everything. Its repeat still ends the list without an error, so lists that work today keep working.
  • Docs: the --paginate help, README, getting-started page and skill say it fails rather than returning part of a list.

Tests

  • Unit tests: each case has a test in internal/client/pagination_test.go, written first. Eight failed on main.
  • Changed tests: two existing tests changed meaning. TestDoPaginatedStopsWhenOffsetIsIgnored became TestDoPaginatedFailsWhenAFullPageRepeats. TestDoPaginatedIgnoresLinkToAnotherHost became TestDoPaginatedFailsOnALinkToAnotherHost, which still checks that only one request is made.
  • Whole suite: go vet ./... and go test for every package, one at a time: pass.
  • Live, read-only, on a test org: 21 --paginate lists across cc, admin, calling, messaging and device return the same counts on main and on this branch, up to 600 items for messaging rooms list, which pages by Link header. admin people list errors identically on both.
  • Live plain-array check: two small pages of the plain-array flow list (--size 5 --page 0/1) hold different flows. The endpoint honours page, so main did cut such lists off at 100.

🤖 Generated with Claude Code

https://claude.ai/code/session_01JAtGHcFAKjQdB6dwDKd8mW


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

--paginate returned part of a list as if it were the whole list when:
- a SCIM list's server page was smaller than the page asked for, although
  totalResults said there was more;
- an endpoint repeated a page, ignoring the paging parameters;
- the next-page link pointed at another host;
- a Contact Center list returned a full plain array, or {data} with no
  page metadata (only the first 100 items were read).

Full plain arrays and pages without metadata now lead to another request,
SCIM lists are read to their totalResults, and the other cases fail with
"incomplete list". A repeated page longer than the page asked for still
ends the list, since the endpoint returned everything at once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JAtGHcFAKjQdB6dwDKd8mW

This branch has not been deployed

No deployments
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