Skip to content

fix(rag): actionable errors for unreadable Excel files; read titled sheets right - #5812

Merged
kovtcharov-amd merged 4 commits into
amd:mainfrom
kovtcharov:kalin/elegant-gould-949f8c
Oct 26, 2026
Merged

kovtcharov-amd merged 4 commits into
amd:mainfrom
kovtcharov:kalin/elegant-gould-949f8c

Conversation

@kovtcharov

Copy link
Copy Markdown
Contributor

Uploading a damaged .xlsx, a legacy .xls or password-protected workbook, or one with no data used to fail with a 500 carrying openpyxl's raw text ("File is not a zip file"). An empty workbook "indexed" as nothing but sheet names. Each now shows a clear "can't be read" message saying what to do, the same way damaged PDFs do. Spreadsheets with a merged title row above the table, like a lab report, lost their column names (LDL, HDL), so questions about a column found nothing. Those now index with the right labels.

The crash in #2741 itself no longer reproduces on main: openpyxl was added to the ui extra in #2932, and #5643 made the UI show the backend's reason. On a cold GAIA_HOME, a simple sheet and a multi-sheet workbook with formulas and merged cells both upload and index. This PR fixes what was still wrong with Excel files after that.

Closes #2741

Test plan

  • pytest tests/unit/rag/test_xlsx_extraction.py: real LibreOffice-saved fixtures (formulas with cached values, merged title row, merged note, empty sheet, real .xls), plus corrupt, empty, .xls-named and missing-openpyxl cases, through both RAG and POST /api/documents/upload
  • pytest tests/unit/rag tests/unit/chat/ui/test_library_index_errors.py tests/unit/chat/ui/test_server.py: 535 passed
  • npx vitest run src/components/__tests__/UnsupportedFeature.test.tsx src/components/__tests__/DocumentLibrary.test.tsx and npx tsc --noEmit
  • python util/lint.py --all passes
  • Real server on an empty GAIA_HOME with live Lemonade embeddings: valid workbooks return 200; a corrupt, a blank and a renamed .xls workbook each return 422 with corrupted / empty_file / unsupported_workbook and a remedy, on both /upload and /upload-path

🤖 Generated with Claude Code

… sheets right

A damaged .xlsx, a legacy .xls or password-protected workbook, or one with
no cell values reached the Agent UI as a 500 carrying openpyxl's text (or,
for the empty one, indexed as nothing but sheet names). They are now
permanent "can't be read" failures (HTTP 422) with a remedy, the same path
damaged PDFs take.

A merged title row above a table was taken for the header, so the real
column names (LDL, HDL) became values with empty labels and answers about
a column could not find it. Single-cell title rows above a row of labels
are now kept as titles, and a blank header cell is labelled ColN.

Closes amd#2741

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added rag RAG system changes tests Test changes performance Performance-critical changes labels Oct 26, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Verdict: Approve with suggestions

A damaged, legacy .xls, password-protected or empty Excel file used to fail with a raw library error or index as nothing. Each now gets a clear "can't be read" message with a fix, the same way damaged PDFs do. Spreadsheets with a title row above the table now keep their real column names. The logic is sound and tested against real saved workbooks, through both RAG and the upload route. Nothing blocks the merge.

  • The Agent UI API doc still lists the old error kinds. The document-index section names only corrupted, encrypted and empty. It should also name empty_file, which was already missing, and the new unsupported_workbook, so integrators see every value the API returns.
  • One edge case in the title-row detection: a one-cell label above rows that are all text can be misread as a title. Optional to fix.

Real-world evidence

N/A here: no evidence bundle was produced for this run. The PR description reports a real server on an empty GAIA_HOME with live Lemonade embeddings, where valid workbooks returned 200 and corrupt, blank and renamed-.xls workbooks each returned 422 with the right kind and a remedy on /upload and /upload-path. This lane didn't capture that output, and there's no Agent UI screenshot of the new toast. The toast is covered by a vitest render test. For any surface not exercised here, the verdict rests on static review and the author's report.

🔍 Technical details

Issues

🟡 API doc out of sync with the error_kind contract (docs/sdk/sdks/agent-ui.mdx:1243-1245). The PR adds unsupported_workbook to PERMANENT_INDEX_FAILURES, DocumentResponse.error_kind and the TS Document type, but the doc still says corrupted, encrypted or empty. empty_file was already missing. Per CLAUDE.md, every doc describing a changed contract should be updated together.

    set to `corrupted`, `encrypted`, `empty`, `empty_file` or
    `unsupported_workbook` when retrying can't help until the file is fixed.

(The second line of the original paragraph, the file is fixed., gets folded in. Adjust the suggestion range when you apply it.)

🟢 The title-row heuristic can promote a data row to the header (src/gaia/rag/sdk.py, first_wide block). Take a sheet of ["Medications"], ["Atorvastatin", "daily"], ["Ezetimibe", "weekly"]. The first wide row has no numeric cell, so Medications becomes a title and Atorvastatin, daily becomes the column names. Only the numeric guard on rows[first_wide] protects against this. One option is to require a following row before treating the leading rows as titles. Another is to accept the case and add a test that pins the behaviour. Not blocking: the common lab-report shape works and the fallback still indexes all the text.

🟢 index_document gained an xlsx_status key next to pdf_status and pptx_status, but nothing documents it. If the eval harness ever reports per-format status (eval/retrieval/harness.py reads only pdf_status), it will need the new key. Worth a line in the stats docstring.

Strengths

  • The new error follows the existing permanent-failure path (*_status → UnreadableDocumentError → 422 + error_kind → UI hint), so there's no new plumbing. Library text stays out of the user message, and a test asserts that.
  • The OLE2 magic-byte check catches a renamed .xls and password-protected .xlsx before openpyxl runs, and real LibreOffice-saved fixtures (cached formula values, merged cells, a real .xls) make the tests reflect real files.
  • ImportError for a missing openpyxl is re-raised with the install hint and isn't swallowed, which keeps the fail-loudly rule.

kovtcharov and others added 2 commits October 25, 2026 21:55
The RAG lane installs no UI extras, so the route and _index_document tests
could not import fastapi there.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A single-cell label above rows of text was taken for a title, so the first
data row became the column names. A one-cell row is now a title only when
it is merged across the table, or when a row of labels and then a row with
numbers follow it.

Documents every error_kind the document routes return, including the
already-missing empty_file.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added the documentation Documentation changes label Oct 26, 2026
Without it both new xlsx test files skip wholesale there, which the
module-skip check rightly fails.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added the devops DevOps/infrastructure changes label Oct 26, 2026
@kovtcharov-amd
kovtcharov-amd added this pull request to the merge queue Oct 26, 2026
Merged via the queue into amd:main with commit dda6d5b Oct 26, 2026
51 checks passed
@kovtcharov-amd
kovtcharov-amd deleted the kalin/elegant-gould-949f8c branch October 26, 2026 10:11
@kovtcharov-amd kovtcharov-amd mentioned this pull request Oct 26, 2026
5 of 9 tasks
grtninja pushed a commit to grtninja/gaia that referenced this pull request Oct 26, 2026
## Why this matters

v0.25.2 is a bug-fix release on top of v0.25.1: setup and install no
longer stop at the first failed step, shell and file access handle
Windows paths and text encodings, the Agent UI and desktop app stop
showing misleading states, and document search, email and skills each
lose a handful of rough edges. 55 commits since v0.25.1; notes are in
`docs/releases/v0.25.2.mdx` and credit 15 outside contributors.

## Test plan

- [x] `python util/validate_release_notes.py docs/releases/v0.25.2.mdx
--tag v0.25.2` passes
- [x] `mintlify validate` (from `docs/`) passes
- [x] `python util/check_doc_links.py --internal-only`, `python
util/check_doc_versions.py` and `node
installer/version/bump-ui-version.mjs --check` pass
- [x] `python util/check_component_core_api.py --release-version 0.25.2`
passes
- [x] `pytest tests/unit/test_docs_json_release.py
tests/unit/test_check_component_core_api.py
tests/unit/test_release_tag.py
tests/unit/test_hub_core_version_gate.py`: 156 passed
- [ ] CI green on the merge commit
- [ ] `release_train_dryrun.yml` passes on that commit before the RC tag

## Evals to re-run on the RC tag

LLM-affecting PRs merged without per-PR evals; run these on
`v0.25.2-rc1`:

- `gaia_shell` and shell/safety (amd#5794, amd#5751, amd#5768)
- `gaia_honesty` (amd#5753)
- `gaia_skills_tasks` and `gaia_skills_lifecycle` (amd#5422, amd#5755)
- `rag_retrieval` and `rag_quality` (amd#5742, amd#5754, amd#5761, amd#5817, amd#5812)
- email scenarios (amd#5767, amd#5811)
- `tool_selection` and `error_recovery` (amd#5732)
- Claude provider thinking replay (amd#5072)
- memory categories (amd#5818 merged; amd#5756 has not)

## Release checklist

- [ ] Freeze main, wait for green CI on the exact commit, pass
`release_train_dryrun.yml`, then push `v0.25.2-rc1`
- [ ] Extend the changelog if main gains commits before the tag
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

devops DevOps/infrastructure changes documentation Documentation changes performance Performance-critical changes rag RAG system changes tests Test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

I upload an xlsx file and want AI to comment on the LDL level but this erro occured

2 participants