Skip to content

fix: handle AttributeError in trending command when running in Docker (fixes #138)#212

Open
algojogacor wants to merge 1 commit into
donnemartin:masterfrom
algojogacor:fix/trending-attributeerror-docker
Open

fix: handle AttributeError in trending command when running in Docker (fixes #138)#212
algojogacor wants to merge 1 commit into
donnemartin:masterfrom
algojogacor:fix/trending-attributeerror-docker

Conversation

@algojogacor

Copy link
Copy Markdown

Summary

Fixes #138 - gh trending raises an AttributeError when running in Docker.

Problem

The gh trending command fetches an RSS feed from http://github-trends.ryotarai.info/rss/. When running in Docker (or when the network is unavailable), the feedparser returns malformed entries or fails entirely, causing an AttributeError traceback.

While a previous fix (PR #129) added error handling for missing summary attributes, the title and link attributes remain unprotected, and the network fetch itself has no error handling.

Changes

gitsome/github.py

  • Wrap feedparser.parse() in try/except with a user-friendly error message when the network is unavailable
  • Add check for None or empty entries before processing

gitsome/table.py

  • Handle missing link attribute in feed entries gracefully (catches KeyError, IndexError, and AttributeError)

gitsome/formatter.py

Testing

  • gh trending now shows a friendly error message instead of a traceback when the RSS feed is unreachable
  • Malformed feed entries (missing title, link, or summary) are handled gracefully
  • Normal operation is unaffected when the feed is available

Fixes donnemartin#138

The gh trending command raises an AttributeError when running in Docker
because the RSS feed from github-trends.ryotarai.info may be unreachable
or return malformed entries without the expected attributes.

Changes:
- github.py: Wrap feedparser.parse() in try/except with user-friendly
  error message when network is unavailable
- github.py: Check for None/empty entries before processing
- table.py: Handle missing 'link' attribute in feed entries gracefully
- formatter.py: Handle missing 'title' attribute in feed entries
  (extends the existing fix for missing 'summary' from PR donnemartin#129)
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.

gh trending AttributeError running in Docker

1 participant