fix(docx): clamp the declared table cell span to the table limits #5702
All Vouch review confidence checks passed
Residual risk 0.22 = Change Risk (0.40) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.40 · 315 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.344
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #5702"
general
weight: 0.35
1AbdullahButt
<!-- Thank you for contributing to Docling! -->
a docx table lost the whole table, and all the text in it, when one cell declared a huge span. the backend sized the table grid from
w:gridSpan,w:gridBeforeandw:gridAfter, so a value abovemax_table_cellsmadeTableDatareject the table and the table walk swallowed the error. now each declared value is clamped, the way the pptx, xlsx, html, asciidoc and latex backends already clamp a spanChecklist:
Review evidence:
_handle_tablesindocling/backend/msword_backend.pyreads the cell span withtc.grid_spanand the row offsets withrow.grid_cols_beforeandrow.grid_cols_after, then setsnum_colsto the largest of those sums. a small file can declare 1000001 there.TableDatarefuses a grid abovesettings.max_table_cells(1000000), and_walk_linearcatches that error withexcept Exceptionand only logs it at debug level, so the user gets a document with no table and none of the text from that table, and no messageAGENTS.mdsays a declared value such as acolspanmust be limited, and namesclamp_span. the pptx backend does that since #5603, and the xlsx, html, asciidoc and latex backends use it too. the docx backend was the only one that did noti converted a real .docx (a plain 2x2 table with one extra attribute) with a real
DocumentConverter:master:
this PR:
the same holds for
w:gridBefore, which names a row that starts latea normal table is unchanged, and a span that is wider than the declared grid is still honoured, as
test_table_with_incomplete_gridexpects. only the values above the limits moveChecks:
pytest tests/test_backend_msword.py-> 125 passed, 14 failed, 13 errors. the 14 failures and the 13 errors are the ones master gives in this sandbox as well, they need LibreOffice, which is not installed hereruff format --checkandruff checkon both files -> cleanlen(doc.tables) == 0) and they pass with itnote: 26 open PRs touch
docling/backend/msword_backend.pyortests/test_backend_msword.py, and #4716, #4587 and #4369 are within 50 added lines of this change. none of them fixes a declared table span, so the overlap is in file position only