Skip to content

Fix --page-all stopping after the first page - #165

Open
Timtech4u wants to merge 1 commit into
elevenlabs:mainfrom
Timtech4u:fix/page-all-pagination
Open

Timtech4u wants to merge 1 commit into
elevenlabs:mainfrom
Timtech4u:fix/page-all-pagination

Conversation

@Timtech4u

Copy link
Copy Markdown

Fixes #138

--page-all is documented as fetching every page, but it issued a single request and exited 0. The pagination loop only continues when it can read a next-page token from nextPageToken and send it back as pageToken. This API does not use those names, and the spec does not set x-fern-pagination, so every list response was treated as the last page. voices search returned the first page with has_more: true. history list did the same, and that response has no cursor field at all (last_history_item_id is what start_after_history_item_id expects).

--page-all now follows the pagination fields declared on each operation:

  • next_page_token
  • cursor / next_cursor
  • start_after_history_item_id / last_history_item_id
  • last_doc / next_doc
  • page (with has_more, or meta.total when the response has no cursor)
  • offset / page_size

If a later page fails, or the response says has_more is true but does not include a token we can send, the command exits non-zero and says the results are incomplete. Hitting --page-limit is still a normal stop.

Tests use a mock server and do not need an API key. cargo test --test pagination_test covers each pagination shape, including a failure on the second page. cargo test --lib openapi::pagination::tests checks every paginated operation in the spec.

`--page-all` only continued when the response had `nextPageToken`, which this
API does not use, so list commands exited 0 after a single page. Follow the
pagination fields each operation documents, and exit non-zero when a later
page fails or `has_more` is true without a token.

Fixes elevenlabs#138
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.

--page-all returns only the first page for cursor-paginated endpoints, with has_more true and exit code 0

1 participant