New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid error when feedreader is in debug log mode and RSS entry comes without title and pubDate #16316

Merged
merged 1 commit into from Aug 31, 2018

Conversation

Projects
None yet
3 participants
@exxamalte
Contributor

exxamalte commented Aug 31, 2018

Description:

Under rare circumstance an uncaught error is produced and the affected RSS entry is discarded: when the feedreader component is in debug log mode, and at least one entry in the RSS feed does not contain a title and does not contain a pubDate tag.

In this case an error like the following is logged (the following comes from a tox test run):

core.py                    110 ERROR    Error doing job: Future exception was never retrieved
Traceback (most recent call last):
  File "/Users/username/home-assistant/home-assistant/.tox/py36/lib/python3.6/site-packages/feedparser.py", line 398, in __getattr__
    return self.__getitem__(key)
  File "/Users/username/home-assistant/home-assistant/.tox/py36/lib/python3.6/site-packages/feedparser.py", line 356, in __getitem__
    return dict.__getitem__(self, key)
KeyError: 'title'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/Cellar/python/3.6.4_4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/Users/username/home-assistant/home-assistant/homeassistant/components/feedreader.py", line 74, in <lambda>
    EVENT_HOMEASSISTANT_START, lambda _: self._update())
  File "/Users/username/home-assistant/home-assistant/homeassistant/components/feedreader.py", line 119, in _update
    self._publish_new_entries()
  File "/Users/username/home-assistant/home-assistant/homeassistant/components/feedreader.py", line 164, in _publish_new_entries
    self._update_and_fire_entry(entry)
  File "/Users/username/Programming/home-assistant/home-assistant/homeassistant/components/feedreader.py", line 146, in _update_and_fire_entry
    entry.title)
  File "/Users/username/home-assistant/home-assistant/.tox/py36/lib/python3.6/site-packages/feedparser.py", line 400, in __getattr__
    raise AttributeError("object has no attribute '%s'" % key)
AttributeError: object has no attribute 'title'

I amended the RSS fixture for one test case to capture this issue.

Related issue (if applicable): n/a

Pull request in home-assistant.github.io with documentation (if applicable): n/a

Example entry for configuration.yaml (if applicable):

feedreader:
  urls:
    - <URL of RSS feed where entries are missing title and pubDate tag>

logger:
  default: info
  logs:
    homeassistant.components.feedreader: debug

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass
  • Tests have been added to verify that the new code works.

@balloob balloob added this to the 0.77.2 milestone Aug 31, 2018

@balloob balloob merged commit 26d39d3 into home-assistant:dev Aug 31, 2018

5 checks passed

Hound No violations found. Woof!
WIP ready for review
Details
cla-bot Everyone involved has signed the CLA
continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage decreased (-0.005%) to 93.76%
Details

@wafflebot wafflebot bot removed the in progress label Aug 31, 2018

balloob added a commit that referenced this pull request Aug 31, 2018

@balloob balloob referenced this pull request Aug 31, 2018

Merged

0.77.2 #16324

@exxamalte exxamalte deleted the exxamalte:feedreader-log-fix branch Sep 1, 2018

cyberjacob pushed a commit to cyberjacob/home-assistant that referenced this pull request Sep 4, 2018

@home-assistant home-assistant locked and limited conversation to collaborators Dec 10, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.