fix(typescript): await getNextPage() in generated pagination snippet - #17563
fix(typescript): await getNextPage() in generated pagination snippet#17563devin-ai-integration[bot] wants to merge 1 commit into
Conversation
…on snippet Co-Authored-By: bot_apk <apk@cognition.ai>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
There was a problem hiding this comment.
Single-line generator fix wrapping page.getNextPage() in an await expression, plus regenerated seed fixtures and a changelog entry. The AST change is correct and the enclosing snippet is already async (it opens with await client...). No issues found.
To request another review, comment /ai-review on this pull request.
SDK Generation Benchmark ResultsComparing PR branch against median of 5 nightly run(s) on Full benchmark table (click to expand)
main (generator): generator-only time via --skip-scripts (includes Docker image build, container startup, IR parsing, and code generation — this is the same Docker-based flow customers use via |
|
Review — no breaking changes found.
Approving. |
Description
Linear ticket: Refs
The manual page-by-page pagination example emitted into generated TypeScript SDK
README.md/reference.md/snippet.jsondid not type-check (reproduced on generator 3.88.3):Root cause: the snippet is not a text template — it is built as a TypeScript AST in
maybeLeverageInvocationinGeneratedDefaultEndpointImplementation.ts, which created the assignment RHS as a plaincreateCallExpressionforpage.getNextPage(). The pagination runtime (Page.getNextPage()andCustomPager.getNextPage()) isasyncand returnsPromise<this>, so assigning its result back into thePage-typedpagevariable is a type error. The neighbouringfor await (const item of pageableResponse)snippet is generated separately and was always correct, which is why only the manual loop was broken. The fix wraps the call ints.factory.createAwaitExpression, emittingpage = await page.getNextPage();(the enclosing snippet is already an async context, since the initialawait client...()call is emitted there too).Changes Made
page = await page.getNextPage();from the pagination leverage-code AST inGeneratedDefaultEndpointImplementation.maybeLeverageInvocation.ts-sdkseed outputs (README, reference, snippet.json) across all pagination fixtures.Audit of sibling snippets / other languages
BinaryResponse: the activestream()assignment is synchronous, and thearrayBuffer()/blob()/bytes()alternatives are shown as awaited comments.SyncPage.nextPage()returnsSyncPage<T>synchronously; Go's example already usespage, err = page.GetNextPage(ctx)with error handling; Python (iter_pages()), PHP (getPages()), C#, Rust and Swift pagination sections don't use this direct-async-assignment shape.Testing
pnpm compile,pnpm seed:build,pnpm lint:biome,pnpm format:fixclean;pnpm seed test --generator ts-sdk --skip-scripts251/251 passing; nopage = page.getNextPage();remains anywhere underseed/.Gap: there is no existing test that extracts fenced TypeScript blocks from a generated
README.md/reference.mdand runstscover them. Seed's TS project verification (.fern/verify.sh→pnpm build && pnpm test) compiles the generated SDK and dynamic-snippet tests, but never the documentation snippets, so this class of bug (README-only, non-compiling example code) is currently uncaught by CI. The snapshot test added here pins the exact generated text, but a real README compile check would need new infrastructure.Link to Devin session: https://app.devin.ai/sessions/79649fbe4aa54feb8b07597bbf1de100
Open in Devin Desktop: https://app.devin.ai/desktop/session/79649fbe4aa54feb8b07597bbf1de100?variant=devin