Skip to content

fix(pptx): keep converting when a shape type is unrecognized - #2570

Open
Aimery Barrault (aImErYbArRaUlT) wants to merge 1 commit into
microsoft:mainfrom
aImErYbArRaUlT:fix/pptx-unrecognized-shape-type
Open

Aimery Barrault (aImErYbArRaUlT) wants to merge 1 commit into
microsoft:mainfrom
aImErYbArRaUlT:fix/pptx-unrecognized-shape-type

Conversation

@aImErYbArRaUlT

@aImErYbArRaUlT Aimery Barrault (aImErYbArRaUlT) commented Oct 1, 2026 •

Copy link
Copy Markdown

Fixes #2569.

PptxConverter reads shape.shape_type while walking a slide (in _is_picture, _is_table, and the group-shape check). If python-pptx can't map the shape, that attribute access raises NotImplementedError: Shape instance of unrecognized shape type, which propagates out of convert() and fails the entire presentation - every slide lost because of one shape.

What was wrong

One unrecognized shape takes the whole deck down. On docling's fixture the error is:

PptxConverter threw NotImplementedError with message: Shape instance of unrecognized shape type

and nothing is returned, even though the surrounding slides are ordinary.

The fix

A small _shape_type_or_none() helper that returns the shape's MSO type, or None when shape.shape_type raises NotImplementedError. The three type checks call it instead of reading shape.shape_type directly, so an unrecognized shape is simply "none of the handled types" and falls through. It doesn't crash, and because the fall-through reaches the has_text_frame branch, any text the shape carries is still recovered rather than dropped. No change for well-formed decks: for a recognized shape the helper returns the identical value.

Evidence

Verified against docling's fixture for exactly this case, powerpoint_unrecognized_shape.pptx:

  • Before: PptxConverter threw NotImplementedError ... Shape instance of unrecognized shape type; nothing returned.
  • After: all 3 slides convert, and the unrecognized shape's own text ("Text in an unrecognized shape") is recovered.
  • Well-formed decks are unaffected: for a recognized shape the helper returns the identical value, so their output is byte-identical.

Tests

Added tests/test_pptx_unrecognized_shape.py, built on a real, self-authored fixture: a <p:sp> with no placeholder, no preset or custom geometry, and a <p:cNvSpPr> without txBox="1" - exactly the element python-pptx cannot map - injected into a slide's shape tree. It asserts the fixture genuinely raises NotImplementedError (so it stays a real test of this path), that _shape_type_or_none returns None, that the shape is treated as neither a picture nor a table, and end-to-end that one such shape does not abort the deck: the presentation still converts and the surrounding text survives.

Scope

Robustness only. Targets the NotImplementedError from an unrecognized shape_type; no change to output for well-formed decks. Independent of the separate reading-order change (filed next).

Checklist

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

@aImErYbArRaUlT

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

shape.shape_type raises NotImplementedError for a shape python-pptx
cannot map, and it was read unguarded in _is_picture, _is_table, and the
group-shape check, so one unrecognized shape aborted the whole
presentation. A _shape_type_or_none helper returns the shape's type, or
None on that error; the three checks use it, so an unrecognized shape is
treated as none of the handled types and falls through. The rest of the
deck still converts and the shape's own text is recovered.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PPTX: one unrecognized shape type aborts the whole presentation

1 participant