[typespec-ts] Continuation-token paging stops after the first page
- Dominant language
- TypeScript
- Stars
- 27
- Forks
- 90
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 156
Description
## Description
Generated pageable iterators for JSON and XML continuation-token operations stop after the first page. Each operation returns two items on its first response and a token for the next request, but iteration completes without issuing that request, so only 2 of the expected 4 items are returned.
## Spector service
- Spec: https://github.com/microsoft/typespec/tree/main/packages/http-specs/specs/payload/pageable
- Scenarios:
- `Payload_Pageable_ServerDrivenPagination_ContinuationToken_requestQueryResponseBody`
- `Payload_Pageable_XmlPagination_listWithContinuation`
## Reproduction
```ts
const jsonItems = await collect(
client.serverDrivenPagination.continuationToken.requestQueryResponseBody({
foo: "foo",
bar: "bar",
}),
);
const xmlItems = await collect(client.xmlPagination.listWithContinuation());
```
## Actual behavior
```text
JSON items: 2 (expected 4)
XML items: 2 (expected 4)
```
No second request is sent. The generated paging configuration only identifies the page item property through `itemName`; it does not contain metadata for extracting the response continuation token or injecting it into the next request's declared query parameter. The generic paging helper consequently treats the first response as the final page. The same metadata gap occurs for the token represented in the XML response model.
## Expected behavior
The generated pageable iterator should:
1. Extract the property marked with `@continuationToken` from each response, including an XML response body.
2. Place that token in the operation parameter marked with `@continuationToken` for the next request.
3. Continue until the response no longer contains a token.
Both scenarios should yield all four items and issue the expected second request.
Contributor guide
Research direction
Start with the generated pageable iterators for the two named Spector scenarios: Payload_Pageable_ServerDrivenPagination_ContinuationToken_requestQueryResponseBody and Payload_Pageable_XmlPagination_listWithContinuation. Trace how itemName and continuation-token metadata reach the generic paging helper for JSON and XML responses. Done means both scenarios issue the second request, pass its token, and collect all four items.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100