Honor the page query param instead of documenting it as a no-op
[!NOTE]
Decision recorded: the parameter wiring lands, convergence is deferred
page means two different things depending on the SDK, and this PR does not change that — it documents it. Verified by execution in all six SDKs (stub server advertising Link: rel="next", asking for page: 3 of a 4-page collection):
SDK Requests issued Items returned Meaning of page Go [3]1 selects the page TypeScript, Python, Ruby, Kotlin, Swift [3, 4]2 starting offset — the walk continues to the end
This predates this PR. On main, TypeScript's generated doc for everythingCompletedCards already reads @returns All BucketCardsGroup across all pages while passing page straight into the query. The behavior has held since the first operations declared @httpQuery("page"). This PR widens it from 18 operations to 56; it does not introduce it.
The decision is to merge as-is. Converging the five auto-paginating SDKs on Go's single-page semantics means new per-call control in five paginators and five generators, and it changes documented, shipped behavior for the 18 pre-existing operations — a breaking change that belongs in the v0.13.0 breaking window with its own red proofs and the breaking label. Tracked in #566, which carries the evidence table, the per-SDK follow-loop locations, and the recommendation.
Recorded on the anchor review thread, where 22 review findings of this class are gathered.
Review blockers cleared
Three blockers were found after the divergence analysis. All three were reproduced before being fixed.
1. Kotlin options classes silently reordered their constructors — f5c30fd5
Generated options classes are data classes whose parameters all carry defaults, so callers may construct them positionally. Constructor position is public API, and kotlin/README.md promises append-only evolution.
The natural emission order broke that on its own: optional query params in spec order, then the synthetic maxItems last. Because maxItems is last, any new query parameter displaces it — page was just the first to try, to sixteen shipped classes:
ListCampfireLinesOptions(sort, direction, maxItems)
-> ListCampfireLinesOptions(sort, direction, page, maxItems)
so ListCampfireLinesOptions(null, null, 50) silently stopped capping at 50 items and started requesting page 50.
TypeEmitter now emits from a pin — kotlin/.../generated/options-param-order.json — recording the shipped order per class. Pinned params hold position, new ones append, dropped ones fall out. Across the whole tree versus origin/main: 16 classes append-safe, 0 reordered, 22 newly created.
The pin is generated into the tree beside the sources so check-kotlin-generated-drift.sh treats a stale pin as drift, and is read from the committed copy even when --output points at a scratch directory — otherwise the drift gate would reset the baseline it exists to verify.
Guard: :generator:test, now run in CI beside :basecamp-sdk:check. Red proof — orderOptionsParams reduced to returning the natural order:
OptionsParamOrderTest > several new parameters append in natural order, after the pinned ones() FAILED
OptionsParamOrderTest > a newly added parameter is appended after the pinned ones() FAILED
OptionsParamOrderTest > ordering never drops or duplicates a parameter the spec declares() FAILED
OptionsParamOrderTest > the pin wins over spec order for parameters it already covers() FAILED
7 tests completed, 4 failed
2. The compatibility overload was emitted where nothing changed — 26913bca
The bridge went to every paginated operation with an optional query param — 55 of them — but only 22 had actually moved from bare PaginationOptions to their own options class. An operation that always had its own options class never had a PaginationOptions signature to stay compatible with, and giving it the bridge anyway leaves two applicable one-argument candidates.
Emission is now keyed on PAGINATION_OPTIONS_COMPAT_OVERLOADS, a frozen roster: 55 overloads before, 22 now, with all 22 changed-type operations bridged and none of the 33 unchanged-type operations bridged.
Guard: two compile-time assertions in PaginationTest, one per direction. Red proof — narrowing removed, tree regenerated:
e: PaginationTest.kt:624:43 Overload resolution ambiguity between candidates:
e: PaginationTest.kt:625:44 Overload resolution ambiguity between candidates:
> Task :basecamp-sdk:compileTestKotlinJvm FAILED
Lines 624–625 are BookmarksService::listMyBookmarks and SearchService::search, left unconstrained on purpose.
Follow-up on the same thread — 2b880b81. The bridge first took a non-null PaginationOptions, which is narrower than the signature it replaces: a caller holding a PaginationOptions? variable matched neither candidate. It now keeps the old signature verbatim, options: PaginationOptions? = null, with the operation's own options class non-null beside it — exactly one of the pair may carry the default, or a bare list(id) is ambiguous, and the default belongs to the pre-existing one.
suspend fun list(recordingId: Long, options: ListCommentsOptions): ListResult<Comment>
/** Source-compatibility overload: the signature this operation had before ... */
suspend fun list(recordingId: Long, options: PaginationOptions? = null): ListResult<Comment> =
list(recordingId, ListCommentsOptions(maxItems = options?.maxItems))
everyPreExistingCallShapeStillResolves type-checks all six shapes — no options, explicit null, non-null value, nullable variable, named nullable, and the new options class. Red proof against the non-null bridge:
e: PaginationTest.kt:654:30 Argument type mismatch: actual type is 'PaginationOptions?', but 'PaginationOptions' was expected.
> Task :basecamp-sdk:compileTestKotlinJvm FAILED
Residual, stated in the generated KDoc: for the 22 that keep a bridge, an untyped callable reference needs an expected type — the narrower cost.
3. The Go portability test did not compile on 32-bit — 6c0d4df6
overflowing := math.MaxInt32 + 1 is a constant expression, not the runtime construction the comment claimed, so the whole package failed to build wherever int is 32 bits:
GOOS=linux GOARCH=386 go test -c -o /dev/null ./pkg/basecamp
page_param_test.go:157:17: cannot use math.MaxInt32 + 1 (untyped int constant 2147483648) as int value in assignment (overflows)
Follows the guard todolists_test.go already carries for the identical MaxInt32 narrowing — skip under strconv.IntSize < 64, build MaxInt32+1 by incrementing. The in-range half needs no guard, so TestPageParamAcceptsMaxInt32 now pins that the largest representable page still reaches the wire.
GOOS=linux GOARCH=386 go test -c -o /dev/null ./pkg/basecamp REAL_EXIT=0
GOOS=linux GOARCH=arm go test -c -o /dev/null ./pkg/basecamp REAL_EXIT=0
go test ./pkg/basecamp -run TestPageParam REAL_EXIT=0 (23 + 2 subtests)
4. Each SDK now documents page in its own shipped docs — fd85c473
"See SPEC section 8" only helps someone who has the spec repo, and Python's generated services carry no docstrings at all. Every README now says what page does in that package, with a pointer to #566:
| SDK | Where | Says |
|---|---|---|
| Go | go/README.md — new ## Pagination | a positive Page fetches exactly that page and disables auto-pagination; names the unpaginated endpoints |
| TypeScript | typescript/README.md — ### The page option | starting offset; { page: 3 } on 10 pages returns 3–10; pair with maxItems |
| Python | python/README.md — ### The page keyword | same, with page=3, max_items=50 |
| Ruby | ruby/README.md — ### The page keyword | same, with page: 3, max_items: 50 |
| Kotlin | kotlin/README.md — ### The page option | same, with ListProjectsOptions(page = 3, maxItems = 50) |
| Swift | swift/README.md — ### The page option | same, with .init(page: 3, maxItems: 50) |
kotlin/README.md also records the constructor-order pin under the compatibility policy, since that is now the mechanism backing the append-only promise.
Rebased onto #560 — page is a pointer now — 2d6186a9
#560 dropped prefer-skip-optional-pointer, so every optional query parameter generates as a pointer: ListProjectsParams.Page is *int32. All six trees were regenerated under the new policy rather than hand-resolved — the two generated-file conflicts (go/pkg/generated/client.gen.go, ruby/.../types.rb) were taken from main and reproduced by make generate.
The 36 wrapper call sites stopped compiling (cannot use page (variable of type int32) as *int32 value in struct literal). pageParam now returns (*int32, error) — nil for the out-of-range usage error — and the declarations became var page *int32. The MaxInt32 guard and its single #nosec G115 justification moved with it.
The new policy makes absence expressible, so TestPageParamOmittedWhenUnset pins it: a zero Page must put no page on the wire. It is a guard, not a red proof — it passes on main too, which is the point.
Re-verified after the rebase:
behavior-model.json byte-identical to origin/main (#560 did not touch it)
go test ./pkg/basecamp -run TestPageParam REAL_EXIT=0 (23 subtests + 3)
GOOS=linux GOARCH=386 go test -c -o /dev/null ./pkg/basecamp REAL_EXIT=0
GOOS=linux GOARCH=arm go test -c -o /dev/null ./pkg/basecamp REAL_EXIT=0
red proof, test file only on rebased origin/main REAL_EXIT=1 (23/23 subtests fail)
Only the Go tree moved: the other five regenerated byte-identical, and the three known timestamp-only files (ruby/.../metadata.json, ruby/.../types.rb, typescript/.../metadata.ts) were content-diffed before being restored.
Regression the pointer flip exposed — 413eeaa4
Widening ListEntries's params guard from "status is set" to "status is set OR a page is selected" means the params struct is built for a page-only call too — and Status: &opts.Status on an unset string is a non-nil pointer to "", sent as an empty status= rather than omitted, displacing the server's active-entries default. Latent until #560: before optional query params were pointers, an unset Status was a zero value that omitempty dropped.
page_param_test.go:197: expected no status parameter when only Page is set, got "page=3&status="
--- FAIL: TestPageParamDoesNotForceSiblingFilters
REAL_EXIT=1
Status now goes through omitzero, matching every other wrapper of this shape. Swept for the rest of the class: rg ':\s+&opts\.' go/pkg/basecamp/*.go finds one other site, reports.go:86, whose guard still fires only when the value is non-empty. TestPageParamDoesNotForceSiblingFilters stays as the regression test.
Out of scope, tracked separately
Generated Swift service methods carry no method-level documentation at all — no summary, no - Parameter for path or required query parameters (rg -c '\- Parameter' swift/Sources/Basecamp/Generated/Services/*.swift returns zero matches on this branch and on origin/main). A review finding framed that as incomplete coverage introduced here; it is pre-existing and broader, so it is filed as #569 rather than absorbed.
Go's wrapper *ListOptions.Page fields carried a NOTE — "The page number itself is not yet honored due to OpenAPI client limitations" — because the Smithy spec never declared @httpQuery("page") on the underlying operations. This PR declares it on every list-class operation whose BC3 endpoint honors ?page= server-side, regenerates all six SDKs, and wires the Go wrappers through to the generated params.
Op list (38 operations gain page)
GetAnswersByPerson, GetPersonProgress, GetProgressReport, GetProjectTimeline, GetProjectTimesheet, GetQuestionReminders, GetRecordingTimesheet, ListAnswers, ListCampfireLines, ListCampfireUploads, ListCampfires, ListCards, ListClientApprovals, ListClientCorrespondences, ListClientReplies, ListComments, ListDocuments, ListEventBoosts, ListEvents, ListForwardReplies, ListForwards, ListGaugeNeedles, ListGauges, ListMessages, ListPeople, ListProjectPeople, ListProjects, ListQuestions, ListRecordingBoosts, ListRecordings, ListScheduleEntries, ListTemplates, ListTodolistGroups, ListTodolists, ListTodos, ListUploads, ListVaults, Search
Pattern matches the Everything ops (and GetMyNotifications/ListMyDrafts/GetBubbleUps/ListMyBookmarks) that already declared @httpQuery("page").
Server-side verification (bc3): every included op class resolves to a controller using geared pagination (set_page_and_extract_portion_from, which reads params[:page]) or, for Search, the SearchPagination concern that reads params[:page] directly.
Deliberately excluded (index actions verified unpaginated in bc3 — they return the full list):
ListWebhooks(webhooks#index:@bucket.webhooks)ListMessageTypes(categories#index:@category_set.categories.sorted)ListQuestionAnswerers(questions/answers/by_creator#index: full sorted list)
Their Go wrapper docs now say the page number is ignored rather than implying it will work someday — while stating that a positive value still short-circuits auto-pagination, which is what the code actually does (if opts.Page > 0 { return ... }, bypassing the Limit truncation). Seven doc sites across webhooks.go, message_types.go, campfires.go (chatbots), vaults.go (upload versions), people.go (pingable), and checkins.go (answerers).
(Noticed in passing: the pre-existing Smithy doc on ListQuestionAnswerers claims Link-header pagination; correcting that would touch the behavior model, so it is left for a follow-up.)
Generator fixes (own commit, e5b1fadf7)
Both the Kotlin and Swift generators equate "paginated" with "returns a bare array", so an operation whose paginated array is nested under a response key (x-basecamp-pagination.key) takes the wrapped branch with half its plumbing missing:
- Kotlin
TypeEmitteromitsmaxItemsandtoPaginationOptions()from the operation's options class, whileServiceEmitter's wrapped branch passedoptionsstraight torequestPaginatedWrapped, which wantsPaginationOptions. - Swift builds its
queryItemsarray only for the plain and array-paginated shapes, yet the wrapped call site passesqueryItems:regardless — so a wrapped op's query params would never reach the URL.
Latent, not a regression. GetPersonProgress is the only wrapped-paginated operation today and it had no optional query params, so its options parameter already was PaginationOptions (Kotlin type-checked) and there were no query items for Swift to emit. The defect only surfaces once a wrapped op gains an optional query param — which page does.
Latency proof: with these generator fixes applied to a pristine origin/main worktree, make kt-generate-services swift-generate produces zero generated-output changes (only the three generator sources stay dirty). The fix commit therefore contains no generated files.
Go wrapper wiring
All 37 wrapper sites across 23 go/pkg/basecamp files now pass opts.Page into the generated params (if opts.Page > 0), and the "not yet honored" NOTE is replaced with "Page, if positive, fetches only that page and disables auto-pagination" — the disables-auto-pagination semantics are unchanged. GaugesService.List and GaugesService.ListNeedles take no options struct today, so they only gain the compile-fix nil params and page cannot reach the wire in Go for those two operations. Giving them one is a breaking signature change — Go has neither overloading nor default arguments — so it is left for the breaking window and tracked in #570.
Known divergence: what page means (documented, not resolved)
Review flagged this on 22 threads; the full analysis and the per-SDK evidence live on one anchor thread. Short version, verified by execution in all six SDKs against a stub server advertising Link: rel="next", asking for page: 3 of a 4-page collection:
| SDK | Requests observed | Items returned | Meaning of page |
|---|---|---|---|
| Go | [3] | 1 | selects the page |
| TypeScript, Python, Ruby, Kotlin, Swift | [3, 4] | 2 | starting offset — the walk continues to the end |
This predates the PR. It has held since the first operations declared @httpQuery("page"); on main, TypeScript's generated doc for everythingCompletedCards says @returns All BucketCardsGroup across all pages while passing page into the query. This PR widens it from 18 operations to 56 rather than introducing it.
Converging the five on Go's semantics means new per-call single-page control in five paginators and five generators, and it changes documented, shipped behavior for the 18 pre-existing operations — a breaking behavioral change that deserves its own PR and the breaking label. Issue #566 tracks it.
What this PR does instead of shipping the divergence silently:
- SPEC §8 gains a
The page Query Parametersubsection with the table above, whymax_itemsis not a page selector, and the pre-existing framing. It states which operations acceptpagerather than how many: a hardcoded count has nothing gating it and goes stale the next time the op list moves (6acad89b). It also names both carve-outs: six operations carry the pagination trait but nopage(their Basecamp index actions return the whole collection), andGetMyNotificationsdeclarespagewith no pagination trait. - 55 of the 56
pagemembers in the Smithy spec carrySemantics vary by SDK; see SPEC section 8, which flows into generated doc comments. The exception isGetMyNotifications, which has no pagination trait — no SDK follows links for it — so it documents its own single-page behavior instead (370c3d18). - The Kotlin and Swift generators now emit OpenAPI parameter descriptions as KDoc / doc comments on options types — neither emitted per-parameter docs at all before, so the pointer would otherwise have reached only Go, TypeScript, and Ruby. (Python's generated services carry no docstrings at all; noted in #566.)
Kotlin source compatibility (review finding, fixed)
A paginated operation that gains its first optional query param moves from options: PaginationOptions? to options: <Operation>Options? — a source break against the pre-1.0 append-only guarantee in kotlin/README.md. My own PaginationTest needing a rewrite was the tell.
The generator now emits a compatibility overload beside each affected method:
suspend fun list(options: PaginationOptions): ListResult<Project> =
list(ListProjectsOptions(maxItems = options.maxItems))
It takes PaginationOptions without a default, so a bare list() stays unambiguous and resolves to the primary method. 55 overloads emitted.
Proof: PaginationTest.kt:592 is reverted to the exact pre-PR call shape, personProgress(456, PaginationOptions(maxItems = 3)), and compiles unchanged with the Kotlin suite green. That call site now stands as a regression test for the guarantee.
Proofs
- Red-first:
TestPageParamReachesWire(httptest, asserts?page=3reaches the wire for one representative op per wrapper file) run against pristineorigin/mainplus the test file only: 23/23 subtests FAIL withexpected ?page=3 on the wire, got ""(REAL_EXIT=1). On this branch: 23/23 PASS. - behavior-model.json: byte-identical to origin/main — it is not in this PR's file list at all, having come out unchanged from every regen.
- Regen convergence: a second
make generateis idempotent — the post-regen diff is byte-identical to the pre-regen diff after restoring three timestamp-only files (ruby/.../metadata.json,ruby/.../types.rb,typescript/.../metadata.ts; content-diffed to confirm timestamp-only before restore). - Six-tree diff shape: additive
pageparam plus the mechanical options-class restructuring that follows when an op gains its first optional query param (custom Options classes replacing barePaginationOptionsin Kotlin/Swift/Python/Ruby signature reflows; TS param plumbing; new Go params structs). - Cross-SDK compile health: the new custom options class for
GetPersonProgressbroke one hand-written Kotlin test that constructedPaginationOptionsdirectly (PaginationTest.kt:592); updated toGetPersonProgressOptions. Swift's equivalent test already used its custom struct. No other hand-written layer referenced a changed signature. - gosec G115: narrowing
intto the generatedint32at 36 call sites tripped integer-overflow warnings. Routed through apageParamhelper that rejects out-of-range values withErrUsage, mirroringRepositionTodolist's existingMaxInt32guard, so the#nosecjustification lives in one place.TestPageParamRejectsOutOfRangeis red-proofed:math.MaxInt32 + 1errored and never reached the wire. - Cite the CI job numbers on the final green run.