Read one page at a time, with a continuation for the next
Every list that pages by Link header gains a sibling that reads exactly one page and returns a continuation for the next one, in all seven SDKs. This is the seam a stale-while-revalidate cache, an infinite-scroll view or an agent needs: one request per call, the items, and a handle it can persist and pass back.
let page = try await account.projects.listPage()
let next = try await account.projects.listPage(continuation: page.next)
What
- 63 siblings per SDK, one for each operation with
x-basecamp-paginationstylelink(62 bare arrays plus the wrappedGetPersonProgress). They're named after the walking method withPageappended:listPage,list_page,ListPage,personProgressPage, and so on. Cursor-stylePollEventsandPollInboxget none. Each generator refuses a sibling name that collides with another method on the service. Go's service layer is hand-written, so Go's 63 are too, over a small generic helper. - Inputs: the walking method's arguments, minus the item cap, plus an optional continuation. A positive
pagestill picks the starting page. When a continuation is given, the request is a GET to it verbatim, and the other query params are ignored. - Output:
Page<T>withitems,next(null on the last page),totalCount(X-Total-Count, null when absent, unlikeListMeta's 0) andhasNext. ForGetPersonProgress, the walk's wrapper is returned witheventsas aPage. - The continuation is the absolute URL of the next page: the
rel="next"target, resolved against the response URL. It's a plain string, so it round-trips through storage. - Same-origin at both ends, and same-path on the way in. When the continuation is produced, a
Linkoff the request's origin is refused, as the walk already refuses to follow one. When it's followed, it must be an absolute URL on the configured base URL's origin, and its path must be the path of the first request this call's path parameters build. Otherwise it's refused withusagebefore any request is sent. A persisted continuation is input that whoever can write the caller's storage controls, and one saved from project A's list and passed with project B's ids would otherwise read A's. - One code path. In each SDK, the walk and the sibling share the first-request building, the next-link resolution and the origin check. The walking methods' signatures are unchanged, and so is
ListMeta. Sharing the first request changes the walks' wire behaviour in two ways, the same in all seven SDKs. A non-positivepage, which already meant no pin, is now left out of the request instead of being sent aspage=0(orpage=-1). And each next link a walk follows is resolved against the URL that answered and checked against the URL requested for that page, not against wherever a redirect landed. The Python, Ruby and Rust transports don't follow redirects, so they already behaved that way. MIGRATING describes both. - SPEC.md §8 "Single-Page Reads" specifies the record, the algorithm and the rules. MIGRATING.md has an Unreleased note with each SDK's names, and each SDK's README has a short example.
Decisions
- Naming follows the brief, not hey-sdk. In hey-sdk, every paginated read returns a
Pageandclient.nextPage(page)walks on. Basecamp's list methods already return a walkedListResult, and changing them would break every caller. So the page read is a sibling, and its continuation is a value the caller holds rather than a method on the client. The field names line up with hey-sdk where the concepts match:totalCountandhasNext. - The continuation is a plain string in every SDK, not a wrapper type, so persisting it needs no codec. hey-sdk's
nextPageis a plain string too. - A continuation is scoped to its call's path (SPEC §8 step 2c). The comparison is exact, on the parsed path with its percent-encoding kept, against the first request the call builds from its own path params, so no SDK normalizes paths. Every path param is an id, so there is nothing to canonicalize. Go probes that path through the generated request builder (a request editor records it and aborts before anything is sent, with no auth or hooks) rather than spelling paths by hand. TypeScript's generator passes the route template and params, and Kotlin's passes the account-relative path. Ruby, Python, Swift and Rust already held the path or the operation in their page helper.
- A continuation needs none of the arguments it overrides. Step 2c needs only the call's path, so a continuation resumes a search with no query, a recordings list with no type, or a todo list with any status, and a
pageis never validated alongside one. Go's probe skips those checks. The query parameters the walks require, Search'sqand ListRecordings'type, are optional in the page siblings' signatures: an optional options field in TypeScript,q: nilin Ruby,Nonein Python and Rust, nullable in Kotlin and Swift. Go already took""as absent. With no continuation and the parameter missing, every SDK raisesusagebefore any request (SPEC §8 step 1). Path parameters stay required. This matches the rule fizzy-sdk#265 settled on. - A 304 keeps the page's
LinkandX-Total-Count. The ETag caches in Go, Swift and TypeScript stored only the body, and a 304 replayed only its own headers, so a revalidated page lost itsnextand total and a walk stopped after page one. Each cache entry now keeps both headers. A header the 304 sends wins, and a missing one comes from the entry. Go's disk cache writesresponses/<key>.entry2: one atomic file, with the headers on its first line. Older SDKs don't read that name, so entries written before the upgrade are misses once. Ruby, Python and Rust have no ETag cache, and Kotlin'senableCacheisn't read by anything. A 304 is merged onto the entry its request revalidated, not whatever a concurrent read stored since, and the merge is written back only while the stored entry still holds that ETag; an emptyETagnever becomes a validator. Go restores the firstLinkfield, the one a page read parses, so a revalidated page resumes exactly as its 200 did. No conformance runner can turn on a cache, so the tests are per SDK. - Whether a refusal before any request fires operation hooks varies by SDK. SPEC doesn't pin whether operation hooks see an argument error raised before a request, and the SDKs already differ on other argument validation. Go reports these refusals through its operation hooks; the others raise before the operation starts.
- The SDK can't see identity. The path carries the account but not the user or token, so a caller persisting continuations keys them by identity, operation and path params. SPEC says so.
- A consequence for redirects: a page answered from another path hands out a continuation on that path, which the original params then refuse. Read from the first page again. Basecamp doesn't redirect list paths today.
- No item cap on a page read. Trimming a page and then handing out its continuation would skip the trimmed items for good. Go's siblings take the walk's options struct, so
Limitis accepted there but ignored, and the doc comments say so. - Rust calls the type
PageRead<T>, becausebasecamp_sdk::Page<T>is already the walk's cursor type and every walking method returns it. - Go's person progress sibling is
TimelineService.PersonProgressPage, returningPersonProgressPageResult, because Go's walk lives onTimelineService. - Kotlin's
resolveUrlnow follows RFC 3986. It used to put any relativeLinkunder the origin root, which is wrong for a target without a leading slash, and the walk shares the resolver. Basecamp sends absolute links, so walks against Basecamp read the same pages as before. - Next links resolve against the URL that answered, and are checked against the URL requested (SPEC step 5). The check uses the requested URL, not the configured base URL, because a redirect to another origin is exactly what it has to catch.
- A continuation wins; an empty one reads the first page. When a continuation is given, the call's filters and
pageare ignored, and every sibling's documentation says so. totalCountis a non-negative decimal integer or null.-3,+3and1_000read as null.- Page reads fire no per-page pagination hook (Ruby's
on_paginate), on the first page or after a continuation. That hook reports a walk's progress by page number, and a continuation has none. Operation and request hooks still fire. - Conformance runners now require a page read to raise when a
urlOrigincase expects a cross-origin next link to be rejected. Before, a sibling that handed the foreign link back without raising still passed. - Redirect following is not changed here. Each transport follows redirects for every operation as before, so page reads do too.
- The conformance case for a cross-origin next link doesn't pin the error. The SDKs raise different errors for it, and
errorRaisedhas no control-sibling form for a header-only fault. Each SDK's unit tests assert the failure. - TypeScript now passes
baseUrlto every service, not only projects, people and account, because the continuation check needs it. A cached 304 now also keeps its response URL, so a relative next link resolves.
Conformance
pagination.json gains 17 cases tagged page-read, run by all seven runners:
- one request with the next continuation;
- a relative link resolved against the response URL;
- the last page;
- a continuation followed verbatim;
- a cross-origin
Linkrefused; - a cross-origin or relative continuation refused with
usageand zero requests; - a continuation for another operation, account or person refused with
usageand zero requests, a next link to another path refused when followed, and one on the call's own path followed; - the wrapped variant;
- Search's page read with only a continuation, sending the continuation's
q, and with neither, refused withusageand zero requests. A third reads Search's first page withqand follows itsnext, pinningqon both requests.
Two new case fields drive them: continuation (a literal for the first call, {origin} in it standing for the mock server's origin) and followNext (call again N times with the previous next, passed through its string form). responseMeta reads itemCount, hasNext, totalCount, next (with the mock origin written as {origin}) and personId. Several runners skipped requestCount on any case tagged link-header, so they now enforce it on page-read cases, where one request per call is the point. No skips were added.
A new assertion type, requestQueryParam, pins one query parameter of a recorded request (index picks the request, as for requestPath): a string expected compares its first value, an array every value in order, and a missing parameter fails. All seven runners implement it, with unit tests for its failing branches; the schema accepts only a string or a non-empty list of strings as expected, since runners stringify other JSON values differently. Besides the two Search cases, it now pins page on the continuation-following case and on the two malformed-Link walk cases. Fixture descriptions that said no assertion could pin a query string now say the cases predate it.
Tests
Each SDK tests the projects and person-progress siblings:
- the happy path with
nextandtotalCount; - the last page, with a null
nextandtotalCount; - following a continuation sends exactly one request to that URL;
- a cross-origin
Linkis refused; - a cross-origin or relative continuation is refused with
usageand no request.
Each SDK also tests that Search's page read sends a continuation with no q, and that with neither it raises usage before any request. Go, Swift and TypeScript test a bare 304 on a first page and on a continuation, a 304's own Link winning, and a walk continuing past a revalidated first page. Swift and TypeScript also test a 304 answered after a concurrent 200 replaced the entry, and an empty ETag; Go tests that a bare 304 restores the Link field the 200 was read by.
The generators' tests cover sibling emission and the collision refusal. Go also checks that all 63 siblings send the walk's first request with the walk's OperationInfo.
scripts/check-deprecation-parity now expects twice the markers on Search in Swift, Kotlin and Python, because the search page options carry the same three deprecated parameters.
Declined from review
- Ruby re-encodes a continuation's query. Faraday parses and rebuilds the query, so percent-encoding and key order can differ from the
LinkURL. Rails reads it the same, and the walk has always sent continuations this way. - Ruby's runner pins the query WebMock recorded, which is normalized. No case depends on raw order or a duplicated scalar key; the runner says so where it checks.
q: ""is sent as given by Ruby, Swift and Rust and refused by Go. SPEC §8 step 1 refuses a missing argument; an empty one is the caller's value and the server answers it.- A continuation read retries as the walk's followed pages do, not with the operation's own policy. The walk has always read page 2 onward this way; giving continuations a different policy than the walk would make the two reads of one page behave differently.
- TypeScript keys a retried request's cache entry by its first attempt's credential. Unchanged by this PR; the cache key and retry path predate it.
- Userinfo in a
nextlink is accepted by Go, TypeScript, Ruby, Swift, Kotlin and Rust. Only Python's transport turns userinfo into Basic auth that replaces the bearer token, so only Python refuses it. Go's transport leaves an existingAuthorizationheader alone, fetch refuses credentialed URLs, and Rust's SDK setsAuthorizationafter the URL is parsed. - Go, Kotlin and Rust read only the first
Linkfield. Their header APIs return one field where the other SDKs join them. BC3 sends oneLinkfield, and Go pins the single-field read on purpose (TestCache_A304RestoresTheLinkFieldThe200WasReadBy). Joining fields in three SDKs is a separate change. - TypeScript resolves a relative
nextagainst the base URL when a response carries no URL. Only a synthesized response (a stub) lacks one; Basecamp'snextis absolute, and a wrong path is still refused by the continuation's path check. - Swift falls back to
url.pathwhenURLComponentscan't parse. The fallback only makes the path comparison fail, which refuses the continuation, so it fails closed. - The conformance schema's looser spots (
responseMetaon null, Python's bool-as-int, an optionalexpected, a zero-requestrejectedcase) are runner hardening across all seven runners, not this feature; no case here depends on them. - Kotlin's runner
mockOriginkeeps default ports. The mock server never listens on 80 or 443. - Python accepts falsy non-string continuations.
Noneand""mean "first page" by design; other non-strings are refused. - Go's on-disk cache can still race across processes. The write-back guard holds within one process; two processes sharing a cache directory can interleave, and the worst case is a stale page read once.
Open question
- Page has no
prev. Basecamp'sLinkheaders carrynextonly, so aprevwould have to be synthesized frompage, which a verbatim continuation doesn't expose. Left out; say if a caller needs it.
No Smithy or openapi.json change, so this is not a spec merge for the release job.