fix: validate block_sizes and split_overlap in HierarchicalDocumentSplitter#11688
Open
Kunal-Somani wants to merge 2 commits into
Open
fix: validate block_sizes and split_overlap in HierarchicalDocumentSplitter#11688Kunal-Somani wants to merge 2 commits into
Kunal-Somani wants to merge 2 commits into
Conversation
|
@Kunal-Somani is attempting to deploy a commit to the deepset Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||
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.
Related Issues
Proposed Changes:
HierarchicalDocumentSplitterhad two validation gaps that produced either silent wrong behavior or a confusing error:Empty
block_sizes: ConstructingHierarchicalDocumentSplitter(block_sizes=set())succeeded with no error. Callingrun()then silently returned the input document unsplit, with no warning that nothing was split.split_overlaptoo large: ConstructingHierarchicalDocumentSplitter(block_sizes={5, 3}, split_overlap=4)raised: ValueError:split_overlapmust be less thansplit_length.This error originates from the internal
DocumentSplitterthatHierarchicalDocumentSplitterbuilds per block size. It referencessplit_length, a parameter name that does not exist onHierarchicalDocumentSplitter's public API, and gives no indication of whichblock_sizetriggered the failure.I fixed this by adding explicit validation in
HierarchicalDocumentSplitter.__init__, before delegating to the internalDocumentSplitterinstances:ValueErrorifblock_sizesis emptyValueErrorifsplit_overlapis negativeValueErrorifsplit_overlap >= min(block_sizes), with a message that usesHierarchicalDocumentSplitter's own parameter names and states the exact smallest block size that's the problemHow did you test it?
PYTHONPATH="" hatch run test:unit test/components/preprocessors/test_hierarchical_doc_splitter.py- 17 passed (11 existing + 6 new)hatch run test:types- no issues in 365 source fileshatch run fmt- auto-fixed one formatting issue, all checks now passNotes for the reviewer
This is not a breaking change for any valid existing usage - only inputs that previously either silently did nothing or raised a confusing, implementation-leaking error now raise a clear, actionable
ValueError. Noupgrade:note was added to the release note for this reason; it's filed underfixes:only.Checklist
fix:,feat:,build:,chore:,ci:,docs:,style:,refactor:,perf:,test:and added!in case the PR includes breaking changes.