fix(sdk): follow batch pagination and stop on cancel in both SDKs - #411
Open
us wants to merge 1 commit into
Open
fix(sdk): follow batch pagination and stop on cancel in both SDKs#411us wants to merge 1 commit into
us wants to merge 1 commit into
Conversation
batch_scrape/batchScrape returned only the first status page's data, so any batch over ~100 documents silently lost every page past the first; a cancelled job was also not a terminal branch, so the poll spun until timeout. - poll page 1 to a terminal state (new cancelled branch raises instead of spinning), then follow the next cursor accumulating every page's data - rebuild each page request from the SDK's own base path plus only the skip/limit cursor values, never the server's absolute next URL: reusing it double-prefixes when api_url carries a path (/api) and trusts a host that may not match. seed the seen-set with page 1 so a cursorless/repeat next stops cleanly rather than re-appending or looping - tolerate a null data page (list(None) would crash the Python path; TS already guarded with ?? []) - crawl polls (Python + TS) also gain the cancelled terminal branch - tests: pagination collects all pages, cancel raises without spinning, null data yields []
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug (batch-scrape-plan A4)
batch_scrape/batchScrapepolled the async batch job and, oncompleted, returned only the first status page'sdata. The batch status endpoint returns at most ~100 documents per page with anextcursor, so any batch over 100 URLs silently lost every page past the first — the highest-harm item in the batch plan. Acancelledjob was also not a terminal branch, so the poll span untiltimeout.The fix
cancelledbranch raises instead of spinning. Then follownext, accumulating every page'sdata.skip/limitcursor values, never the server's absolutenextURL. Reusing that URL double-prefixes whenapi_urlcarries a path (/api) and trusts a host that may not match. Theseenset is seeded with page 1 so a cursorless/repeatnextstops cleanly rather than re-appending or looping.nulldata page (list(None)would crash the Python path; TS was already guarded with?? []).cancelledterminal branch (same infinite-hang class).Verified against the real server contract: the SaaS
/v2/batch/scrape/{id}cursor is{origin}{prefix}/{id}?skip=N, engine page size 100,nextnull on the last page,cancelleda genuine engine terminal state. The SDK deliberately stays on/v2/batch/scrape(the paginated surface); native/v1/batch/scrapereturns a fullCrawlStatewith no pagination.Tests
Python 41 pass, TypeScript 19 pass. New: pagination collects all pages, cancel raises without spinning, null-data page yields
[].