Skip to content

rss-bot: Ignore empty lines and comments in feed file - #935

Open
SPY-Github22 wants to merge 1 commit into
zulip:mainfrom
SPY-Github22:fix-rss-bot-empty-feed-lines
Open

SPY-Github22 wants to merge 1 commit into
zulip:mainfrom
SPY-Github22:fix-rss-bot-empty-feed-lines

Conversation

@SPY-Github22

Copy link
Copy Markdown

Problem

Fixes #920.

When the rss-feeds configuration file contains blank lines, whitespace, or comments, rss-bot parsed them as feed URLs. An empty string has an empty netloc, causing os.path.join(data_dir, "") to point to the cache directory itself rather than a file. When the script attempted to open this path, Python raised:

IsADirectoryError: [Errno 21] Is a directory: '/home/zulip/.cache/zulip-rss/'

Changes

  1. Filter out empty lines, whitespace-only lines, and lines starting with # when reading feed_file.
  2. Add a defensive check in the feed processing loop to skip any URL lacking a valid netloc.
  3. Add automated unit test suite in zulip/integrations/rss/test_rss.py verifying:
    • Handling of empty lines and comments without crashing.
    • Correct cache creation for valid feed URLs when interspersed with blank lines.
    • Graceful exit when feed file is missing.

Testing Done

  • Ran automated tests: pytest zulip/integrations/rss/test_rss.py (3 passed).
  • Verified end-to-end execution with test feeds file containing blank lines, comments, and valid feed URLs.

An empty line in the feeds configuration file caused rss-bot to compute
an empty netloc, leading to an IsADirectoryError when attempting to open
the feed hashes cache path.

Skip empty or whitespace-only lines and lines starting with '#' when
reading feed files, and guard against URLs lacking a netloc. Add unit
tests verifying handling of blank lines, comments, and missing files,
and include rss integration dependencies in root requirements.txt for
test execution.

Fixes zulip#920.
@SPY-Github22
SPY-Github22 force-pushed the fix-rss-bot-empty-feed-lines branch from 1000a6b to 5cec695 Compare November 2, 2026 05:30
@zulipbot zulipbot added size: XL and removed size: L labels Nov 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

empty line in feeds file leads to crash

2 participants