Skip to content

fix: Prevent iterate_items from terminating early under server-side filters#747

Closed
vdusek wants to merge 1 commit intomasterfrom
fix/iterate-items-early-termination-with-filters
Closed

fix: Prevent iterate_items from terminating early under server-side filters#747
vdusek wants to merge 1 commit intomasterfrom
fix/iterate-items-early-termination-with-filters

Conversation

@vdusek
Copy link
Copy Markdown
Contributor

@vdusek vdusek commented Apr 21, 2026

Summary

  • DatasetClient.iterate_items (both sync and async) terminated early whenever skip_empty, skip_hidden, or clean=True caused a server-side page to contain fewer than 1000 items, silently dropping the remaining dataset items.
  • The API applies those filters after scanning the [offset, offset+limit) window, so a short page does not imply the dataset is exhausted. The previous current_page_item_count < cache_size shortcut was incorrect under any server-side filter.
  • The request offset was also advanced by the number of items returned rather than scanned, causing subsequent requests to re-scan overlapping windows whenever a filter was active.

Fix

  • Track the scanned window explicitly via a new scanned_items counter and use it to compute the next request offset.
  • Advance scanned_items by effective_limit (the size of the requested window), not by the count of returned items.
  • Terminate only when the server returns zero items (or the caller-supplied limit has been reached).

Tests

  • Added regression tests (sync and async) that simulate an API post-filtering half of every scanned 1000-item window across a 2500-item dataset. They fail on master (loop exits after the first ~500 items) and pass on this branch (all ~1250 non-empty items are yielded).

🤖 Generated with Claude Code

… 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>
@vdusek vdusek added adhoc Ad-hoc unplanned task added during the sprint. t-tooling Issues with this label are in the ownership of the tooling team. labels Apr 21, 2026
@vdusek vdusek self-assigned this Apr 21, 2026
@github-actions github-actions Bot added this to the 139th sprint - Tooling team milestone Apr 21, 2026
@github-actions github-actions Bot added the tested Temporary label used only programatically for some analytics. label Apr 21, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 21, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.27%. Comparing base (6c3b84d) to head (1596ed9).
⚠️ Report is 7 commits behind head on master.

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     
Flag Coverage Δ
integration 95.27% <100.00%> (-0.10%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@vdusek vdusek marked this pull request as draft April 21, 2026 09:36
@vdusek
Copy link
Copy Markdown
Contributor Author

vdusek commented Apr 22, 2026

Closing as this part of codebase will be refactored during #539

@vdusek vdusek closed this Apr 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

adhoc Ad-hoc unplanned task added during the sprint. t-tooling Issues with this label are in the ownership of the tooling team. tested Temporary label used only programatically for some analytics.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants