fix: skip empty ByteStream in HTMLToDocument to avoid noisy lxml logs#11670
Merged
bogdankostic merged 1 commit intoJun 18, 2026
Merged
Conversation
When HTMLToDocument received a ByteStream with empty data (b""), it passed the empty content to trafilatura's extract(), which made lxml emit several ERROR/WARNING log lines internally (e.g. "Document is empty"). The existing try/except could not suppress these because lxml logs rather than raises. Empty ByteStream objects are now skipped before extraction, so lxml is never invoked and no noisy logs are produced.
|
@Srivatsa03 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 |
||||||||||||||||||||||||
bogdankostic
approved these changes
Jun 18, 2026
bogdankostic
left a comment
Contributor
There was a problem hiding this comment.
Looking good, thanks @Srivatsa03! :)
sjrl
pushed a commit
that referenced
this pull request
Jun 22, 2026
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:
When
HTMLToDocumentreceives aByteStreamwith empty data (b""), it passes the empty content to trafilatura'sextract(). Internally lxml then emits several ERROR/WARNING log lines (e.g.Document is empty,discarding data: None) that surface as noise in production logs, even though the component already skips the source gracefully.The existing
try/exceptaroundextract()cannot suppress these because lxml logs the problem internally rather than raising an exception.This PR adds a guard that skips any
ByteStreamwhosedatais empty beforeextract()is called, so lxml is never invoked and no noisy logs are produced. The empty source is skipped with a singleWARNING-level message, consistent with the component's other skip paths.How did you test it?
test_run_empty_bytestreamthat runs the converter on an emptyByteStreamand asserts:trafilatura.extractis never called (mock_extract.assert_not_called()),hatch run test:unit test/components/converters/test_html_to_document.py— 14 passedhatch run test:types— success, no issueshatch run fmt— all checks passedNotes for the reviewer
The fix is intentionally minimal and placed right after the source is read, mirroring the existing skip-on-error pattern in
run(). A release note has been added underreleasenotes/notes/.Checklist
fix:.