feed2exec crashes when echoing {item.author} on a stream which doesn't have it
feed2exec crashes when asked to echo an author field on an incomplete RSS feed.
How to reproduce
- Find an RSS feed which doesn't have author (or maybe some other field) for each of its entries.
- $ feed2exec parse 'https://???.???' --output echo --args '{item.author}'
Expected behavior
Could print an empty string, eventually warn about missing field.
Actual behavior
'Un Auteur'
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/feedparser.py", line 403, in __getattr__
return self.__getitem__(key)
File "/usr/lib/python3/dist-packages/feedparser.py", line 361, in __getitem__
return dict.__getitem__(self, key)
KeyError: 'author'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/bin/feed2exec", line 33, in <module>
sys.exit(load_entry_point('feed2exec==0.17.1', 'console_scripts', 'feed2exec')())
File "/usr/lib/python3/dist-packages/click/core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "/usr/lib/python3/dist-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/usr/lib/python3/dist-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/lib/python3/dist-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/lib/python3/dist-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/usr/lib/python3/dist-packages/click/decorators.py", line 33, in new_func
return f(get_current_context().obj, *args, **kwargs)
File "/usr/lib/python3/dist-packages/feed2exec/__main__.py", line 171, in parse
feed_manager.dispatch(feed, data, lock=False, force=True)
File "/usr/lib/python3/dist-packages/feed2exec/controller.py", line 295, in dispatch
if plugins.output(feed, item, session=self.session, lock=lock) is not False and not force: # noqa
File "/usr/lib/python3/dist-packages/feed2exec/plugins/__init__.py", line 99, in output
args = [x.format(feed=feed, item=item)
File "/usr/lib/python3/dist-packages/feed2exec/plugins/__init__.py", line 99, in <listcomp>
args = [x.format(feed=feed, item=item)
File "/usr/lib/python3/dist-packages/feedparser.py", line 405, in __getattr__
raise AttributeError("object has no attribute '%s'" % key)
AttributeError: object has no attribute 'author'
Environment
- Version: feed2exec 0.17.1
- Operating system: Debian GNU/Linux Testing
- Install method: debian repositories
- URL: ...
- Minimal configuration file: not used