Skip to content

Fix #1534: Handle None response from LLM in PptxConverter#1569

Open
cobyfrombrooklyn-bot wants to merge 1 commit intomicrosoft:mainfrom
cobyfrombrooklyn-bot:fix-issue-1534
Open

Fix #1534: Handle None response from LLM in PptxConverter#1569
cobyfrombrooklyn-bot wants to merge 1 commit intomicrosoft:mainfrom
cobyfrombrooklyn-bot:fix-issue-1534

Conversation

@cobyfrombrooklyn-bot
Copy link

Fixes #1534

Problem

When an LLM client returns None as the message content (e.g., content filtering, API errors, or unexpected responses), PptxConverter crashes with:

TypeError: sequence item 0: expected str instance, NoneType found

This happens on line 139 of _pptx_converter.py where "\n".join([llm_description, alt_text]) is called, but llm_description is None (returned by llm_caption() which has return type Union[None, str]).

Fix

Added or "" fallback after llm_caption() call so that a None return is coerced to empty string, matching the initialized default on line 98. This is a 4-character change.

Test

Added test_pptx_llm_returns_none in test_module_misc.py that:

  • Creates a mock LLM client returning None content
  • Converts test.pptx with the mock client
  • Verifies no TypeError is raised and conversion succeeds

Test fails without the fix (TypeError), passes with it.

Tested locally on macOS ARM (Apple Silicon). Full test suite: 145 passed, 7 skipped/failed (pre-existing, due to missing optional deps like youtube-transcript-api).

When llm_caption() returns None (e.g., LLM returns null content),
the join on line 139 raises TypeError because str.join cannot handle
NoneType items. Added 'or ""' fallback so None is coerced to empty
string, matching the initialized default.

Added test_pptx_llm_returns_none that mocks an LLM client returning
None content and verifies conversion completes without TypeError.
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.

A bug when llm_description got None response from LLM in PptxConverter

2 participants