Skip to content

fix(pptx): prevent crash in PptxConverter when chart title lacks a text frame - #2194

Merged
afourney merged 3 commits into
microsoft:mainfrom
aoright:fix-pptx-chart-title-crash
Sep 3, 2026
Merged

fix(pptx): prevent crash in PptxConverter when chart title lacks a text frame#2194
afourney merged 3 commits into
microsoft:mainfrom
aoright:fix-pptx-chart-title-crash

Conversation

@aoright

Copy link
Copy Markdown
Contributor

Description

This PR resolves a crash where PptxConverter (and PptxConverterWithOCR) throws an AttributeError when converting presentations containing charts whose titles do not have a text_frame.

According to the python-pptx documentation, chart_title.text_frame is None if the title was set directly or programmatically without using the rich text frame API.

Fix

  • Added a text_frame is not None check before reading chart.chart_title.text_frame.text in both converters.
  • Added unit tests for both PptxConverter and PptxConverterWithOCR to verify correct behavior.

辰言 and others added 2 commits July 6, 2026 11:56
…xt frame

Chart title text_frame can be None if the title is set directly or programmatically in python-pptx. Added a None check before attempting to read text.

Signed-off-by: 辰言 <oncwnuIWp30GguOyJ615Fqj8H-yc@git.weixin.qq.com>

Copilot AI 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.

🟢 Approval recommended

Only minor metadata and whitespace nits remain.

Pull request overview

Preserves PPTX chart conversion when a chart title lacks a text frame.

Changes:

  • Guards title extraction in standard and OCR converters.
  • Adds regression tests for both paths.
File summaries
File Review
packages/markitdown/tests/test_module_misc.py Adds regression coverage; remove trailing whitespace.
packages/markitdown/src/markitdown/converters/_pptx_converter.py Guards title extraction; PR metadata should clarify existing fallback behavior.
packages/markitdown-ocr/tests/test_pptx_converter.py Adds OCR regression coverage.
packages/markitdown-ocr/src/markitdown_ocr/_pptx_converter_with_ocr.py Guards OCR chart-title extraction.
Review details

Suppressed comments (2)

packages/markitdown/src/markitdown/converters/_pptx_converter.py:313

  • The surrounding except Exception already catches this AttributeError and returns [unsupported chart], so the previous behavior loses chart content but does not let the converter crash as the PR title and description state. Please update the PR metadata to describe preserving chart conversion, or add an integration case demonstrating an exception path that actually escapes.
            if chart.has_title and chart.chart_title.text_frame is not None:

packages/markitdown/tests/test_module_misc.py:1028

  • These newly added blank lines contain trailing spaces; remove the whitespace so the test file remains clean and passes whitespace-sensitive linting.
  • Files reviewed: 4/4 changed files
  • Comments generated: 0
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

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.

3 participants