Skip to content

fix(excel_parser): keep zero-valued cells when building Excel text chunks - #16287

Merged
wangq8 merged 3 commits into
infiniflow:mainfrom
devYRPauli:fix/excel-parser-keep-zero-cells
Jun 26, 2026
Merged

wangq8 merged 3 commits into
infiniflow:mainfrom
devYRPauli:fix/excel-parser-keep-zero-cells

Conversation

@devYRPauli

Copy link
Copy Markdown
Contributor

What

RAGFlowExcelParser.__call__ (deepdoc/parser/excel_parser.py) builds the per-row text that gets indexed. It skips empty cells with:

if not c.value:
    continue

Because 0, 0.0 and False are 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 dropped 0 loses 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 (None or a blank/whitespace string), keeping 0, 0.0 and False. This mirrors the guard already used by the html() 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:

  • a zero-valued cell is preserved in the output (this fails before the change),
  • a None cell is still skipped.

All excel parser unit tests pass and ruff check is clean.

…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.
@dosubot dosubot Bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Jun 24, 2026
@coderabbitai

coderabbitai Bot commented Jun 24, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7cde0fe5-0891-42bb-9bcd-f9f7152c4b9b

📥 Commits

Reviewing files that changed from the base of the PR and between 4a1b948 and 273ca3d.

📒 Files selected for processing (2)
  • deepdoc/parser/excel_parser.py
  • test/unit_test/deepdoc/parser/test_excel_parser.py
💤 Files with no reviewable changes (2)
  • deepdoc/parser/excel_parser.py
  • test/unit_test/deepdoc/parser/test_excel_parser.py

📝 Walkthrough

Walkthrough

The Excel parser now keeps zero and boolean false cell values by checking only for None or whitespace-only strings. Two unit tests and a workbook helper were added to verify both preserved and skipped cell cases.

Changes

Excel Parser Cell-Value Fix

Layer / File(s) Summary
Cell emptiness fix and unit tests
deepdoc/parser/excel_parser.py, test/unit_test/deepdoc/parser/test_excel_parser.py
The falsy guard in RAGFlowExcelParser.__call__ is replaced with an explicit None-or-whitespace check so that 0, 0.0, and False are retained. A local XLSX helper and two pytest cases verify that zero-valued cells are included and None cells are skipped.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~4 minutes

Possibly related issues

Possibly related PRs

  • infiniflow/ragflow#16318 — Updates the same Excel parser check and adds tests for keeping falsy-but-valid cell values.

Suggested labels

🐞 bug, 🌈 python, 🧪 test

Suggested reviewers

  • wangq8

Poem

🐇 A zero hopped in with a tiny grin,
False and None no longer blur within.
The parser now sees what should stay in sight,
and skips only blanks in the pale moonlight.
Hop, hop—clean cells, and the rabbits delight! 🥕

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR covers the bug, impact, fix, and tests, but it doesn't follow the template and omits the required Type of change section. Reformat the description to match the template, add 'What problem does this PR solve?' and a checked 'Type of change' entry.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the main change: preserving zero-valued Excel cells.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
test/unit_test/deepdoc/parser/test_excel_parser.py (1)

119-123: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add 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

📥 Commits

Reviewing files that changed from the base of the PR and between 919f596 and 1497b99.

📒 Files selected for processing (2)
  • deepdoc/parser/excel_parser.py
  • test/unit_test/deepdoc/parser/test_excel_parser.py

@yingfeng yingfeng added the ci Continue Integration label Jun 24, 2026
@yingfeng
yingfeng marked this pull request as draft June 24, 2026 02:19
@yingfeng
yingfeng marked this pull request as ready for review June 24, 2026 02:19
@codecov

codecov Bot commented Jun 24, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.16%. Comparing base (1dfc240) to head (273ca3d).
⚠️ Report is 12 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@wangq8
wangq8 merged commit dd2c88b into infiniflow:main Jun 26, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants