Skip to content

fix(knowledge): tolerate invalid XLSX creation metadata - #2087

Open
chqcjq wants to merge 1 commit into
TencentCloud:developfrom
chqcjq:codex/fix-xlsx-invalid-created-metadata
Open

chqcjq wants to merge 1 commit into
TencentCloud:developfrom
chqcjq:codex/fix-xlsx-invalid-created-metadata

Conversation

@chqcjq

@chqcjq chqcjq commented Oct 15, 2026

Copy link
Copy Markdown

Summary

Fixes #1878.

Some XLSX exporters put a non-date value such as ASUS in docProps/core.xml's dcterms:created. The workbook's cells can be perfectly readable, but openpyxl rejects the entire document while reading properties, before knowledge extraction can reach the worksheets.

Use a per-call ExcelReader subclass that validates this one field with openpyxl's own DocumentProperties date validator. If it raises ValueError, remove only that creation element from the in-memory properties XML and log a warning. All remaining metadata, styles and worksheet parsing still use openpyxl's normal path.

  • Source bytes are never changed, and no process-wide monkeypatch is used.
  • Normal read_only=True / data_only=True options remain unchanged.
  • Close the input archive on both reader/extraction success and failure.
  • Other metadata failures and damaged worksheets remain errors.
  • Includes a single Unreleased CHANGELOG entry.

The issue is filed as a compatibility request; this implements its selective creation-metadata tolerance, rather than treating arbitrary malformed workbooks as valid.

Issue / existing PR checks

Verification

Windows / Python 3.12 / frozen uv.lock (openpyxl 3.1.5):

  • Before fix: both XLSX and XLSM synthetic workbook tests fail with could not read properties after changing only the creation timestamp to ASUS. The damaged-sheet control also fails at properties before reaching the intended worksheet error.

  • After fix: uv run --no-sync python -m pytest tests/unit/knowledge/test_parse.py -q — 17 passed. New regressions cover XLSX and XLSM cell extraction, unchanged original source bytes, damaged worksheet rejection and rejection of an independently invalid modified timestamp.

  • Focused Ruff check/format and mypy — passed.

  • Local Codex CLI static review of the patch, full parser/tests and installed openpyxl reader/core implementation — completed with no actionable findings. Tests were run separately.

  • make all RUN="uv run --no-sync python -m" PYTEST_JOBS=8 (ASCII path overrides for this Windows checkout) — passed: format/lint, mypy, and 4607 passed / 209 skipped backend tests.

  • Normal Git pre-commit hook (not bypassed) — passed: format/lint/mypy, 24 passed affected tests, and TypeScript + Vite/PWA production build.

Remote CI is separate from local verification; no LLM or business document was used.

Target branch

  • develop
  • Regression tests and Unreleased CHANGELOG

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant