Repository navigation
fix: skip standalone chartsheets in practice XLSX import - #3248
JsSun-1000001000 wants to merge 2 commits into
Conversation
Root-cause analysis of the
|
MohammadHijjawi97
left a comment
There was a problem hiding this comment.
Verified locally on Windows, Python 3.13 with openpyxl from requirements/dev.txt:
tests/api/test_practice.py:50 passedon this head.- With
deeptutor/services/practice/importing.pyreverted todevand the new test kept, it fails withAttributeError: 'Chartsheet' object has no attribute 'max_column', the 500 from #3247. So the test catches the bug. - Ruff check and format on both changed files are clean.
The identity check (ws is sheet against book.worksheets) also works in read_only=True mode. The multi-sheet case in the test, with the second worksheet active, still reads the active sheet.
The red Python Tests (3.13) check here is the Copilot device-flow flake (assert 2 == 1), not this change. #3254 fixes it, and I reproduced that separately.
Description
Fix an unhandled
AttributeError(HTTP 500) inPOST /api/question-notebook/practice/import/previewwhen importing a valid.xlsxworkbook whose active tab is a standaloneChartsheet.In
deeptutor/services/practice/importing.py(parse_rows),book.activecan be aChartsheet, which has neithermax_columnnoriter_rows(). Whenbook.activeisNoneor not inbook.worksheets, this change falls back tobook.worksheets[0]if present; otherwise it raisesValueError("The workbook has no active worksheet")so the router returns HTTP 422 instead of HTTP 500. Multi-worksheet workbooks with a non-first active worksheet continue to read the active worksheet as before.Related Issues
Module(s) Affected
agentsapiconfigcoreknowledgeloggingservicestoolsutilsweb(Frontend)docs(Documentation)scriptstests...Checklist
dev(notmain— see the base-branch selector above).pre-commit run --all-filesand fixed any issues.Additional Notes
Verification
pytest -q tests/api/test_practice.py→50 passed(includes new regressions covering active chartsheet before/after a data worksheet, chart-only workbook returning HTTP 422 instead of 500, and multi-worksheet active tab preservation).ruff check .,ruff format --check .,lint-imports,python scripts/check_architecture.py, andpython scripts/check_repo_hygiene.pyall passed.pre-commit run --all-files: 14/15 hooks passed across the repo (the only error was a pre-existing Windows-onlymypystub check on unrelateddeeptutor/services/subagent/models.py:298); all hooks includingmypypassed on the modified files during commit./learning/practice→ Import): uploading a workbook with an active standalone chartsheet now succeeds with HTTP 200 and previews the questions, and a chart-only workbook returns HTTP 422 cleanly.