Skip to content

fix: initialize md_text in _parse_rss_type to prevent UnboundLocalError - #2164

Merged
afourney merged 2 commits into
microsoft:mainfrom
smedavarapu1:fix/rss-unbound-md-text
Sep 2, 2026
Merged

fix: initialize md_text in _parse_rss_type to prevent UnboundLocalError#2164
afourney merged 2 commits into
microsoft:mainfrom
smedavarapu1:fix/rss-unbound-md-text

Conversation

@smedavarapu1

Copy link
Copy Markdown
Contributor

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.

@afourney
afourney requested a balanced review from Copilot September 2, 2026 05:47

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The fixed titleless-feed path lacks a regression test.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Initializes RSS Markdown output before optional channel metadata, preventing UnboundLocalError for titleless feeds.

Changes:

  • Initialize md_text unconditionally.
  • Append optional channel titles consistently.
File summaries
File Description
_rss_converter.py Safely handles RSS channels without titles.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 1
  • Review effort level: Balanced

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

channel_title = self._get_data_by_tag_name(channel, "title")
channel_description = self._get_data_by_tag_name(channel, "description")
items = channel.getElementsByTagName("item")
md_text = ""
@afourney
afourney merged commit 3661853 into microsoft:main Sep 2, 2026
3 checks passed
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