8000 Avoid error when feedreader is in debug log mode and RSS entry comes without title and pubDate by exxamalte · Pull Request #16316 · home-assistant/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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

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

Merged
merged 1 commit into from
Aug 31, 2018

Conversation

exxamalte
Copy link
Contributor
@exxamalte 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
@ghost ghost removed the in progress label Aug 31, 2018
@balloob balloob mentioned this pull request Aug 31, 2018
@exxamalte exxamalte deleted the feedreader-log-fix branch September 1, 2018 06:39
girlpunk pushed a commit to girlpunk/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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0