Skip to content

fix(pptx): count the header row against the chart table cell cap - #5030

Open
Eapp1e wants to merge 1 commit into
docling-project:mainfrom
Eapp1e:fix/chart-table-cell-cap-header
Open

Eapp1e wants to merge 1 commit into
docling-project:mainfrom
Eapp1e:fix/chart-table-cell-cap-header

Conversation

@Eapp1e

@Eapp1e Eapp1e commented Oct 26, 2026

Copy link
Copy Markdown

Fixes #5029

Problem

build_chart_table() documents that the emitted table is capped at MAX_CHART_TABLE_CELLS cells. The constant itself is described as a backstop on the total cells emitted for one chart.

The cap arithmetic counts data rows only. The header row is emitted afterwards and is never counted. This causes two defects:

  1. A truncated table still exceeds the cap. Two series over 60k categories give 33334 rows x 3 columns = 100002 cells.
  2. A table that would land exactly on the cap is not truncated. One series over 50k categories gives 50000 * 2 = 100000, so 100000 > 100000 is false. The header row then pushes the table to 100002 cells, without a warning.

Fix

Count the header row in both the trigger and the bound:

if (num_data_rows + 1) * num_cols > MAX_CHART_TABLE_CELLS:
    capped_rows = max(1, MAX_CHART_TABLE_CELLS // num_cols - 1)

The warning now reports the same total, including the header row.

Tests

tests/test_backend_pptx.py:

  • test_chart_data_table_capped_at_max_cells now expects MAX_CHART_TABLE_CELLS // 3 - 1 data rows and asserts len(table.table_cells) <= MAX_CHART_TABLE_CELLS. The previous assertion (// 3, then + 1 row) required 100002 cells, so it pinned the defect instead of the documented bound.
  • test_chart_data_table_cap_reached_exactly is new. It covers a table that lands exactly on the cap, where the old code produced no warning and 100002 cells.

Both new assertions fail on current main and pass with the change:

tests/test_backend_pptx.py -k "chart_data_table"   # main: 2 failed
tests/test_backend_pptx.py -k "chart_data_table"   # patch: 2 passed
tests/test_backend_pptx.py                         # patch: 42 passed, 2 skipped

Limits

When the column count alone exceeds the cap (a chart with 50000+ series), the header row still exceeds it. Only column truncation can fix that case. This change does not touch it.

The xlsx chart reader (docling/backend/msexcel_backend.py) uses the same data-row-only arithmetic. I left it unchanged to keep this PR small. I can send a follow-up for it if you want.

@github-actions

github-actions Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

✅ DCO Check Passed

Thanks @Eapp1e, all your commits are properly signed off. 🎉

@mergify

mergify Bot commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

Merge Protections

🟢 Merge protection satisfied — ready to merge.

Show 1 satisfied protection

🟢 Enforce conventional commit

Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/

  • title ~= ^(fix|feat|docs|style|refactor|perf|test|build|ci|chore|revert)(?:\(.+\))?(!)?:

@github-actions github-actions Bot added ai:ci-safe AI triage found no CI-safety concern (advisory) bug Something isn't working pptx issue related to pptx backend labels Oct 26, 2026
@github-actions

github-actions Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

AI triage (advisory)

Checked commit ad61389002. The analysis read the diff only. It did not run code from this pull request.

This pull request counts the header row in the chart table cell limit. It adds tests for build_chart_table().

CI safety: no concern found. A maintainer must still approve CI.

The ai:* labels are advisory. They do not approve CI and they do not add tests:full. A new push runs this check again.

`build_chart_table` capped the emitted table with data rows only, then added the header row outside the bound. A truncated table therefore still exceeded `MAX_CHART_TABLE_CELLS`, and a table that landed exactly on the cap was not truncated at all.

Both the trigger and the bound now include the header row, and the warning reports the same total. The pptx test that pinned the old arithmetic asserts the documented bound instead.

Signed-off-by: Eapp1e <163811520+Eapp1e@users.noreply.github.com>
@Eapp1e
Eapp1e force-pushed the fix/chart-table-cell-cap-header branch from 908310a to ad61389 Compare October 26, 2026 18:19
@github-actions github-actions Bot added ai:ci-safe AI triage found no CI-safety concern (advisory) and removed ai:ci-safe AI triage found no CI-safety concern (advisory) labels Oct 26, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI first review (advisory): no blocker found

This review covers the full diff at ad61389002. It read the code and did not run it.

The fix correctly counts the header row in both the cap trigger and the bound computation. The arithmetic is sound, the two tests cover the two defect cases, and all assertions match the patched values. No issues found.

A maintainer makes the merge decision. This review never approves the pull request.

@github-actions github-actions Bot added the ai:review-lgtm AI first review found no blocker or major issue (advisory) label Oct 26, 2026

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

ai:ci-safe AI triage found no CI-safety concern (advisory) ai:review-lgtm AI first review found no blocker or major issue (advisory) bug Something isn't working pptx issue related to pptx backend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Chart data table exceeds MAX_CHART_TABLE_CELLS by the header row

1 participant