Skip to content

fix(dataset): enforce cumulative btql fetch limits - #2344

Merged
Abhijeet Prasad (AbhiPrasad) merged 2 commits into
mainfrom
abhi-fix-enforce-dataset-btql-limit
Aug 5, 2026
Merged

fix(dataset): enforce cumulative btql fetch limits#2344
Abhijeet Prasad (AbhiPrasad) merged 2 commits into
mainfrom
abhi-fix-enforce-dataset-btql-limit

Conversation

@AbhiPrasad

Copy link
Copy Markdown
Member

resolves https://linear.app/braintrustdata/issue/SDK-201/javascript-dataset-returns-more-records-than-specified-in-internal

The object fetcher treated _internal_btql.limit as a per-request page size instead of a total result cap. It yielded every response and kept following cursors, so fully consuming a dataset or calling fetchedData() could return more records than requested.

Before: limit=3 -> page(2, cursor) -> page(2) -> 4 rows
After: limit=3 -> page(2, cursor) -> page(limit=1) -> 3 rows

Track the remaining record budget across requests, cap each page by both the batch size and that budget, and stop yielding or paginating when it is exhausted. Add fake API coverage for cursor termination, oversized responses, and the interaction between batchSize and the cumulative limit.

The object fetcher treated `_internal_btql.limit` as a per-request page size
instead of a total result cap. It yielded every response and kept following
cursors, so fully consuming a dataset or calling `fetchedData()` could return
more records than requested.

Before: limit=3 -> page(2, cursor) -> page(2)       -> 4 rows
After:  limit=3 -> page(2, cursor) -> page(limit=1) -> 3 rows

Track the remaining record budget across requests, cap each page by both the
batch size and that budget, and stop yielding or paginating when it is
exhausted. Add fake API coverage for cursor termination, oversized responses,
and the interaction between `batchSize` and the cumulative limit.
@AbhiPrasad
Abhijeet Prasad (AbhiPrasad) merged commit fad45c6 into main Aug 5, 2026
48 checks passed
@AbhiPrasad
Abhijeet Prasad (AbhiPrasad) deleted the abhi-fix-enforce-dataset-btql-limit branch August 5, 2026 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants