fix: Prevent iterate_items from terminating early under server-side filters#747
Closed
fix: Prevent iterate_items from terminating early under server-side filters#747
iterate_items from terminating early under server-side filters#747Conversation
… filters When `skip_empty`, `skip_hidden`, or `clean=True` is used, the API post-filters each scanned window, so a page with fewer than 1000 items does not imply the dataset is exhausted. Track the scanned window explicitly, advance the offset by the scanned size (not the returned count), and terminate only on an empty response. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #747 +/- ##
==========================================
- Coverage 95.36% 95.27% -0.10%
==========================================
Files 45 45
Lines 5118 5120 +2
==========================================
- Hits 4881 4878 -3
- Misses 237 242 +5
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Contributor
Author
|
Closing as this part of codebase will be refactored during #539 |
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.
Summary
DatasetClient.iterate_items(both sync and async) terminated early wheneverskip_empty,skip_hidden, orclean=Truecaused a server-side page to contain fewer than 1000 items, silently dropping the remaining dataset items.[offset, offset+limit)window, so a short page does not imply the dataset is exhausted. The previouscurrent_page_item_count < cache_sizeshortcut was incorrect under any server-side filter.Fix
scanned_itemscounter and use it to compute the next request offset.scanned_itemsbyeffective_limit(the size of the requested window), not by the count of returned items.limithas been reached).Tests
master(loop exits after the first ~500 items) and pass on this branch (all ~1250 non-empty items are yielded).🤖 Generated with Claude Code