Repository navigation
fix: stop generator_batching_wbytes from dropping items or yielding an empty batch - #832
Merged
awalker4 merged 2 commits intoNov 19, 2026
Conversation
…n empty batch The early `return iterable` sits inside a generator, so with no byte limit and no batch size it produced no batches at all. And when the first item alone was over the byte limit, the empty current batch was yielded before it. Drop the early return, so no limits means one batch, and only close a batch that has items.
awalker4
approved these changes
Nov 19, 2026
awalker4
left a comment
Contributor
There was a problem hiding this comment.
Approving. I ran the old and new function side by side over the edge cases: no limits, batch_size_limit_bytes=0, generator input, a single oversized item, oversized first/last/both, the exact byte boundary, and max_batch_size alone and combined. The only differences are the two you describe; everything else batches identically. I'll merge main and bump the version on the branch.
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.
What
generator_batching_wbytes(used by the Elasticsearch, OpenSearch and Pinecone uploaders) had two batching bugs:Why
The
return iterableshortcut for "no limits" is inside a generator, so it ends iteration without yielding anything. An Elasticsearch or OpenSearch upload withbatch_size_bytes=0therefore sent no documents and reported no error. Separately, when the first item alone exceeded the byte limit, the still-empty batch was yielded before it — the same empty-batch problem #694 fixed insplit_dataframe.The shortcut is removed, so with no limits everything goes in one batch, and a batch is only closed once it has items. Behaviour with limits is otherwise unchanged; an oversized item still gets a batch of its own.
Validation
Two new tests in
test/unit/utils/test_data_prep.py; both fail on main.pytest test/unit --ignore test/unit/unstructured: 1941 → 1943 passed, same 69 skipped.ruff check .andruff format --checkpass. Adds a CHANGELOG entry and bumps the version to 1.11.27.