Repository navigation
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthrough
ChangesBodyless HTML Fragment Fix
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Suggested labels
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
deepdoc/parser/html_parser.py (1)
73-74: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd a debug log when falling back to the BeautifulSoup root.
This introduces a new bodyless-fragment path, but there’s no log when that fallback is taken. That makes it harder to confirm fragment parsing in production/debug traces.
Suggested change
- root = soup.body or soup + root = soup.body or soup + if soup.body is None: + logging.debug("html_parser: parsing HTML fragment without <body>; falling back to soup root") cls.read_text_recursively(root, temp_sections, chunk_token_num=chunk_token_num)As per coding guidelines,
**/*.py: Add logging for new flows.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@deepdoc/parser/html_parser.py` around lines 73 - 74, Add a debug log in the HTML parsing fallback path so it’s clear when `HtmlParser` uses `soup` instead of `soup.body`. Update the `read_text_recursively` call site in `html_parser.py` to log this branch before invoking `cls.read_text_recursively(...)`, using the existing parser logger or equivalent logging used elsewhere in `HtmlParser`/`parse_html_fragment`. Keep the message specific to the bodyless-fragment fallback so production/debug traces can confirm this path was taken.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@deepdoc/parser/html_parser.py`:
- Around line 73-74: Add a debug log in the HTML parsing fallback path so it’s
clear when `HtmlParser` uses `soup` instead of `soup.body`. Update the
`read_text_recursively` call site in `html_parser.py` to log this branch before
invoking `cls.read_text_recursively(...)`, using the existing parser logger or
equivalent logging used elsewhere in `HtmlParser`/`parse_html_fragment`. Keep
the message specific to the bodyless-fragment fallback so production/debug
traces can confirm this path was taken.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 214e99c9-08d4-4311-8714-a619643e30a3
📒 Files selected for processing (2)
deepdoc/parser/html_parser.pytest/unit_test/deepdoc/parser/test_html_parser.py
|
Addressed the CodeRabbit logging nit in f3fef3b. I added a debug log for the bodyless-fragment fallback and reran:\n\n- |
|
Could a maintainer add the required |
78db4e9 to
f86a0e7
Compare
f3fef3b to
bc5e8e4
Compare
HTML snippets without a body tag should still be traversed so fragment content is indexed instead of dropped. Fixes infiniflow#16422
Record when the HTML parser falls back to the BeautifulSoup root for fragments without a body tag.
bc5e8e4 to
4543e5e
Compare
|
Synced with latest main. Could a maintainer add the ci label so workflows can run? Okay, please review it. |
66f75b8 to
59ffd94
Compare
HTML snippets without a body tag should still be traversed so fragment content is indexed instead of dropped. Fixes infiniflow#16422
Record when the HTML parser falls back to the BeautifulSoup root for fragments without a body tag.
1ae2166 to
1df4bc7
Compare
|
Follow-up: branch is current with |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #16423 +/- ##
=======================================
Coverage 93.16% 93.16%
=======================================
Files 10 10
Lines 717 717
Branches 118 118
=======================================
Hits 668 668
Misses 29 29
Partials 20 20 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
What problem does this PR solve?
Fixes #16422.
RAGFlowHtmlParser.parser_txtalways started traversal fromsoup.body. For HTML fragments without a<body>tag,soup.bodyisNone, so fragment content is not traversed and can be dropped from parsed sections.This PR falls back to the BeautifulSoup root when no body exists, while keeping full HTML document handling unchanged. It also adds a regression test for a bodyless fragment with a heading and paragraph.
Verification:
uv sync --group testuv run pytest test/unit_test/deepdoc/parser/test_html_parser.py -q-> 4 passeduvx ruff check deepdoc/parser/html_parser.py test/unit_test/deepdoc/parser/test_html_parser.py-> All checks passedType of change