Skip to content

fix: initialize md_text in _parse_rss_type to prevent UnboundLocalError#2164

Open
smedavarapu1 wants to merge 1 commit into
microsoft:mainfrom
smedavarapu1:fix/rss-unbound-md-text
Open

fix: initialize md_text in _parse_rss_type to prevent UnboundLocalError#2164
smedavarapu1 wants to merge 1 commit into
microsoft:mainfrom
smedavarapu1:fix/rss-unbound-md-text

Conversation

@smedavarapu1

Copy link
Copy Markdown

Summary

_parse_rss_type only assigned md_text inside if channel_title:, so any RSS feed with no <title> in its <channel> caused an UnboundLocalError on the subsequent md_text += lines.

Fix

Initialize md_text = "" before the conditional block, and change the first assignment to += for consistency.

Reproduction

from markitdown.converters._rss_converter import RssConverter
import io
r = RssConverter()
xml = b'<?xml version="1.0"?><rss version="2.0"><channel></channel></rss>'
r.convert(io.BytesIO(xml), ...)  # UnboundLocalError

Tests

186 existing tests pass. The fix handles: empty channel, description-only channel, title-only channel, and title+description channel.

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.

1 participant