fix: add fallback for heading-less documents in structural chunker - #1032
Open
JairVilleda wants to merge 8 commits into
Open
fix: add fallback for heading-less documents in structural chunker#1032JairVilleda wants to merge 8 commits into
JairVilleda wants to merge 8 commits into
Conversation
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
StructuralChunker.chunk()returned an empty list for documents that contained no markdown headings, causing those documents to be silently dropped from the ingestion pipeline. This PR updates the structural chunking behavior so heading-less content is captured and can be processed instead of being discarded.Issue
Closes #149
Changes
Root cause:
StructuralChunker._extract_sections()only collected content when a markdown heading had been detected. For a document with no headings,heading_stackremained empty, so the document's content was never added to a section andchunk()ultimately returned an empty list.ingestion/chunking/structural_chunker.py— updated section extraction so content from documents without headings is captured instead of being silently droppedTesting
Reproduce the original bug:
StructuralChunker.chunk()returned an empty list.Verify the fix:
python -m pytest tests/unit/test_structural_chunker.py::TestStructuralChunker::test_document_with_no_headings -vScreenshots / Demo
N/A — this is a backend ingestion/chunking change with no visible UI changes. The observable behavior is verified through the structural chunker unit test.
Notes for Reviewers
The implementation was verified with the project's testing/check commands after the fix. No unrelated changes are included in this PR.