Repository navigation
Require exactly two cells for a CSV QA pair - #19008
Conversation
extractQATable dropped empty cells and then paired texts[0] with texts[1]. A CSV row "question,,extra" renders as three <td> cells, so the pair became "question" and "extra". The empty middle column was skipped without notice. Python does not use one rule for every format. rag/app/qa.py:365 requires exactly two fields for CSV. rag/app/qa.py:53 skips empty cells for XLS and XLSX, which is what the Go code already did. Apply the strict rule to CSV only, selected by the source document name. XLS and XLSX keep their current behaviour. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review. 📝 WalkthroughWalkthroughThe QA chunker now applies strict two-cell parsing to CSV HTML tables. Non-CSV tables retain first-two-non-empty-cell handling. Tests cover CSV rejection, CSV acceptance, and non-CSV HTML handling. ChangesQA chunker table parsing
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to CSV QA parsing now rejects rows that do not contain exactly two cells while preserving existing behavior for other formats. The change is localized and covered by tests, with no actionable merge-blocking risk remaining. 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 |
|
The checks on this PR all report SKIPPED. if: ${{ github.event_name != 'pull_request' || (github.event.pull_request.draft == false && contains(github.event.pull_request.labels.*.name, 'ci') && (github.event.action != 'labeled' || github.event.label.name == 'ci')) }}This PR carries I cannot add the label myself. Please add Local results are in the PR body. |
|
Thanks for the fix. The change is minimal and correctly aligns CSV QA pairing with Python ( Findings1. PR description premise is stale relative to current
2. The XLSX regression test is synthetic (Nit) 3. Known out-of-scope gaps (not introduced by this PR, just noting)
Question for the authorSince #19083, XLSX now outputs |
TestQAChunker_XLSXThreeCellsKeepsFirstTwoNonEmpty set output_format to "html" with an .xlsx name. Since infiniflow#18800 the xlsx parser emits "json", so an .xlsx file reaches extractQAJSON and never reaches this branch. The name claimed a path the test does not exercise. Rename it to TestQAChunker_NonCSVHTMLThreeCellsKeepsFirstTwo and use an .xls name, which does still emit "html". Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Upstream infiniflow#19108 moved every test in this package from context.Background() to t.Context() and removed the "context" import from qa_test.go. This branch still called context.Background() in the three tests it adds, so the merge of this branch with main had three calls and no import. Go build failed with "undefined: context" at qa_test.go:140, :160 and :187 in the ragflow_tests_infinity (go) and ragflow_tests_elasticsearch (go) jobs. Use t.Context() in those three tests to match the current convention. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
1. Stale description. Corrected. I also traced the change: The description now states that this change is CSV-only in effect, plus 2. Synthetic XLSX test. Renamed to 3. Out-of-scope gaps. Agreed on both. One correction on the first: the Go text paths already implement Python's continuation rule. Your question. The XLSX JSON path does not apply the Python rule, and it does not pair rows wrongly either. It produces nothing at all.
Measured with one spreadsheet driven through the real parser and the real chunker:
The rendered HTML is byte-identical in both. Only the route changed, and the chunker was never adapted to it. So this needs its own fix, and it is more serious than the pairing gap. I filed it as #19174 with the reproduction test and the bisect. Two repairs are possible. CI. The go jobs were red for a separate reason. #19108 moved this package to |
|
LGTM |
Main's infiniflow#19008 added TestQAChunker_CSVStrictPairAcceptsTwoCells and TestQAChunker_NonCSVHTMLThreeCellsKeepsFirstTwo reading the chunk content from content_with_weight. This branch carries QA content in the canonical text field (ingestion renames it to content_with_weight at the index boundary), so both tests saw an empty string after the merge. Read text like every other QA test adapted in this PR.
Summary
Closes part of #19006. Follows the review on #17902.
Problem
extractQATabledrops empty cells, then pairstexts[0]withtexts[1]:A CSV row
question,,extrarenders as<td>question</td><td></td><td>extra</td>, becauseoffice_table_render.go:238writes one cell per field and keeps the empty ones. The pair becomesquestionandextra. The empty middle column is skipped without notice.Python does not apply one rule to every format:
.csvrag/app/qa.py:365.xls,.xlsxrag/app/qa.py:53Which formats reach this function
csv_parser.goandxls_parser.goemitOutputFormat: "html", so they reachextractQATable.xlsx_parser.gono longer does. #18800 changed its return from"html"to"json"on 2026-08-27, so an.xlsxfile now reachesextractQAJSON.This change is therefore CSV-only in effect, plus
.xls, which keeps its current behaviour. It is a no-op for.xlsx.Change
extractQATabletakes astrictPairsflag. When it is set, a row makes a pair only if it holds exactly two cells. The call site sets it from the source document name, the same signal Python dispatches on..xlsbehaviour does not change.Scope
This stops the incorrect pairing on the HTML table path. Two things stay out:
qa.py:366-369). The Go text paths already do this; the table path does not..xlsxJSON path. It is broken in a different way, reported separately in [Bug]: QA chunking returns zero chunks for every .xlsx file since #18800 #19174.Tests
Three tests in
qa_test.go, all driving the component throughInvoke:TestQAChunker_CSVStrictPairRejectsThreeCells- a.CSVsource withquestion, empty,extraproduces no chunk. The name is uppercase on purpose, to cover the case-insensitive match.TestQAChunker_CSVStrictPairAcceptsTwoCells- a normal two-column CSV row still pairs.TestQAChunker_NonCSVHTMLThreeCellsKeepsFirstTwo- the same three-cell row on an.xlssource still pairsquestionwithextra, so the non-CSV path is unchanged.Results:
Reverting only the source guard and keeping the tests fails one test, and only the intended one:
Note on the local build
go build ./internal/...needsCGO_ENABLED=0on macOS, or it stops on a missingoffice_oxide.h. With cgo off, one unrelated package still fails on this platform:Pdeathsigis Linux only and that file carries//go:build !windows. The same failure appears on a cleanmain, so it is not from this change.