Repository navigation
fix(excel_parser): keep zero-valued cells when building Excel text chunks - #16287
Conversation
…unks RAGFlowExcelParser.__call__ skipped cells with 'if not c.value', which also drops legitimate values like 0, 0.0 and False. A cell holding 0 (e.g. a stock count, price, or boolean flag) was omitted from the indexed text, and since the column header is only emitted alongside a kept value, the header was lost too. Queries about those zero values then retrieve no context. Skip only genuinely empty cells (None or blank string), matching the None guard already used by the html() table path in the same file. Adds regression tests for the zero-valued and empty-cell cases.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
💤 Files with no reviewable changes (2)
📝 WalkthroughWalkthroughThe Excel parser now keeps zero and boolean false cell values by checking only for ChangesExcel Parser Cell-Value Fix
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~4 minutes Possibly related issues
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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)
test/unit_test/deepdoc/parser/test_excel_parser.py (1)
119-123: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd coverage for empty-string and whitespace-only cells.
This regression test currently verifies only
None, but the parser logic also skips""and" ". Please include those cases to lock the full intended behavior.Proposed test update
`@pytest.mark.p2` -def test_call_skips_truly_empty_cells(): - # None / empty-string cells carry no value and should still be skipped. - lines = RAGFlowExcelParser()(_make_xlsx_with_values(["name", "note"], ["widget", None])) +@pytest.mark.parametrize("empty_value", [None, "", " "]) +def test_call_skips_truly_empty_cells(empty_value): + # None / empty-string / whitespace-only cells carry no value and should still be skipped. + lines = RAGFlowExcelParser()(_make_xlsx_with_values(["name", "note"], ["widget", empty_value])) joined = " ".join(lines) assert "note" not in joined, lines🤖 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 `@test/unit_test/deepdoc/parser/test_excel_parser.py` around lines 119 - 123, The test_call_skips_truly_empty_cells function currently only validates that None values are skipped by the RAGFlowExcelParser, but the parser logic also handles empty strings and whitespace-only strings. Expand the test by adding additional assertions or test cases that verify empty strings ("") and whitespace-only strings (" ") are also properly skipped, in addition to the existing None case, to fully validate the intended parser behavior.
🤖 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 `@test/unit_test/deepdoc/parser/test_excel_parser.py`:
- Around line 119-123: The test_call_skips_truly_empty_cells function currently
only validates that None values are skipped by the RAGFlowExcelParser, but the
parser logic also handles empty strings and whitespace-only strings. Expand the
test by adding additional assertions or test cases that verify empty strings
("") and whitespace-only strings (" ") are also properly skipped, in addition
to the existing None case, to fully validate the intended parser behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 7d4da240-3ecb-4b54-9df9-2d51ddddcd14
📒 Files selected for processing (2)
deepdoc/parser/excel_parser.pytest/unit_test/deepdoc/parser/test_excel_parser.py
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #16287 +/- ##
=======================================
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
RAGFlowExcelParser.__call__(deepdoc/parser/excel_parser.py) builds the per-row text that gets indexed. It skips empty cells with:Because
0,0.0andFalseare falsy in Python, this also drops cells that hold a real value of zero. The column header is only emitted together with a kept value, so a dropped0loses its header label as well.Impact
Excel rows with zero-valued data (a stock count of 0, a price of 0, a
False/disabled flag, etc.) are silently omitted from the chunked text. A user asking something like "which items have 0 stock?" gets no matching context. No error is raised, so the loss is invisible.Fix
Skip only genuinely empty cells (
Noneor a blank/whitespace string), keeping0,0.0andFalse. This mirrors the guard already used by thehtml()table path in the same file (if c.value is None).Tests
Added two regression tests to
test/unit_test/deepdoc/parser/test_excel_parser.py:Nonecell is still skipped.All excel parser unit tests pass and
ruff checkis clean.