Skip to content

fix(pptx): handle unsupported 3-D chart types without crashing - #3972

Open
ceberam wants to merge 1 commit into
mainfrom
fix/pptx-3d
Open

fix(pptx): handle unsupported 3-D chart types without crashing#3972
ceberam wants to merge 1 commit into
mainfrom
fix/pptx-3d

Conversation

@ceberam

@ceberam ceberam commented Aug 10, 2026

Copy link
Copy Markdown
Member

Resolves #3970

Problem

A .pptx containing a 3-D chart element (e.g. c:bar3DChart) caused the
entire document conversion to fail with:

RuntimeError: Pipeline SimplePipeline failed
  ← AttributeError: 'lxml.etree._Element' object has no attribute 'iter_sers'

python-pptx has no registered custom element class for 3-D chart types, so
chart.series raises AttributeError on the raw lxml element. One affected
slide was enough to lose the whole deck.

Fix

In _handle_chart, the call to _chart_to_table_data is now guarded with the
same try/except pattern already used one line above for chart.chart_type:

try:
    table_data = self._chart_to_table_data(chart)
except (AttributeError, ValueError, KeyError) as exc:
    _log.warning("Could not extract chart data: %s", exc)
    table_data = None

With table_data = None the rest of _handle_chart already handles the
graceful path — the chart is emitted as a PictureItem with its classification
and caption (if any), tabular_chart is None, and all other slide content
is preserved.

Tests

The existing pptx_chart.pptx fixture was extended with a second slide
containing a c:bar3DChart element (patched in-place from a normal
c:barChart, which is what PowerPoint writes for 3-D bar/column charts).

  • test_chart_parsed_as_classified_picture_with_data — updated to cover both
    slides: the 2-D chart (slide 1) is verified to carry full tabular data; the
    3-D chart (slide 2) is verified to produce a PictureItem with
    tabular_chart = None and no crash.
  • Related chart tests updated to reflect the fixture now having two pictures.
  • Groundtruth files for pptx_chart.pptx regenerated.

Checklist:

  • Documentation has been updated, if necessary.
  • Examples have been added, if necessary.
  • Tests have been added, if necessary.

Signed-off-by: Cesar Berrospi Ramis <ceb@zurich.ibm.com>
@github-actions

Copy link
Copy Markdown
Contributor

DCO Check Passed

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

@mergify

mergify Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Merge Protections

🔴 1 of 2 protections blocking · waiting on 👀 reviews

Protection Waiting on
🔴 Require two reviewer for test updates 👀 reviews
🟢 Enforce conventional commit

🔴 Require two reviewer for test updates

Waiting for

  • #approved-reviews-by >= 2
This rule is failing.

When test data is updated, we require two reviewers

  • #approved-reviews-by >= 2

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)(?:\(.+\))?(!)?:

@ceberam ceberam added bug Something isn't working pptx issue related to pptx backend labels Aug 10, 2026
@codecov

codecov Bot commented Aug 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@dolfim-ibm dolfim-ibm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm

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

Labels

bug Something isn't working pptx issue related to pptx backend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pptx: a 3-D chart (c:bar3DChart) fails the whole document — AttributeError: no attribute 'iter_sers'

2 participants