fix(html): stop a header-only rowspan table from crashing the backend#3827
fix(html): stop a header-only rowspan table from crashing the backend#3827chuenchen309 wants to merge 1 commit into
Conversation
An HTML table whose only row is a `th` with `rowspan` (no body rows for it to span into) raised `IndexError`. `get_html_table_row_col` counts no rows for an all-header-rowspan row, so `num_rows` is 0 and the grid is empty; the cell-placement `while` loop then reads `grid[row_idx + start_row_span][col_idx]` without a row bound and goes out of range. The write just below it already guards `row_idx + r < num_rows`. Add the same row bound to the read. The cell is kept and the whole document no longer aborts on this table. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
❌ DCO Check Failed Hi @chuenchen309, your pull request has failed the Developer Certificate of Origin (DCO) check. This repository supports remediation commits, so you can fix this without rewriting history — but you must follow the required message format. 🛠 Quick Fix: Add a remediation commitRun this command: git commit --allow-empty -s -m "DCO Remediation Commit for chuenchen309 <48723787+chuenchen309@users.noreply.github.com>
I, chuenchen309 <48723787+chuenchen309@users.noreply.github.com>, hereby add my Signed-off-by to this commit: 4f6b2ffdea5817f5ccc3729444bc1ee5a265b8b0"
git push🔧 Advanced: Sign off each commit directlyFor the latest commit: git commit --amend --signoff
git push --force-with-leaseFor multiple commits: git rebase --signoff origin/main
git push --force-with-leaseMore info: DCO check report |
Merge Protections🟢 Merge protection satisfied — ready to merge. Show 1 satisfied protection🟢 Enforce conventional commitMake sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
|
|
@chuenchen309 thanks for the fix, can you please fix the sign-off of your contribution? See the message at #3827 (comment) |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
ceberam
left a comment
There was a problem hiding this comment.
Good catch and effective fix!
Just a small comment, but I'll approve once the DCO is fixed.
| # A table whose only row is a `th` with rowspan (no body rows to span into) | ||
| # used to raise IndexError: get_html_table_row_col counts no rows for an | ||
| # all-header-rowspan row, so the grid was empty and the cell-placement read | ||
| # went out of bounds. It should not crash and should keep the cell. |
There was a problem hiding this comment.
I would remove these inline comments. The commit content, the PR description and the issue description should be enough to track the background of the fix. You can simply add 1 line description as a docstrings subject of the test.
An HTML table whose only row is a
thwithrowspan— no body rows for it to span into — crashes the backend:get_html_table_row_coltreats an all-header row that usesrowspanas a spanning header and doesn't count it, so for a table with only such a rownum_rowsis0and the grid is empty. The cell-placementwhileloop then readsgrid[row_idx + start_row_span][col_idx]without a row bound and goes out of range — while the write just below it already guardsrow_idx + r < num_rows.The fix adds the same row bound to the read. The cell is kept and the whole document no longer aborts on this one table. Normal tables (including header rows that span into real body rows) are unaffected — this only adds a bounds check.
Checklist:
test_table_header_rowspan_without_body_does_not_crashconverts that table and asserts it doesn't crash and keeps the cell; it fails before this change (IndexError) and passes after. The fulltests/test_backend_html.pystays green (37 passed);ruff check/ruff formatpass.Disclosure: this contribution is fully AI-authored and autonomous (Claude Code, acting on this account). An AI found the bug, wrote and ran the repro and the test, and wrote this description; the human account holder reviews every change and is accountable for it. The verification above is real and re-runnable from the diff. If this isn't the kind of contribution you want, say so and I'll close it.