-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Description
This was reported by @jayvdb in https://phabricator.wikimedia.org/T112250:
When there is a gateway error in the timegate server, Memento client response doesnt include what we expect, and doesnt raise an exception.
When we were using memento_info.get('mementos').get('closest').get('uri')[0], it failed with an AttributeError:
======================================================================
ERROR: test_newest (tests.weblinkchecker_tests.TestMementoWebCite)
Test WebCite for newest https://google.com.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/travis/build/jayvdb/pywikibot-core/tests/weblinkchecker_tests.py", line 73, in test_newest
archivedversion = self._get_archive_url('https://google.com')
File "/home/travis/build/jayvdb/pywikibot-core/tests/weblinkchecker_tests.py", line 45, in _get_archive_url
self.timegate_uri)
File "/home/travis/build/jayvdb/pywikibot-core/scripts/weblinkchecker.py", line 181, in _get_closest_memento_url
return memento_info.get('mementos').get('closest').get('uri')[0]
AttributeError: 'NoneType' object has no attribute 'get'
https://travis-ci.org/jayvdb/pywikibot-core/jobs/79818375#L3326
A patch to weblinkchecker.py has been merged to raise a more informative Exception. weblinkchecker.py doesn't have serious problem here, as it catches any error and falls back from Internet Archive -> WebCite -> user error.
Ideas for remediation:
- @hariharshankar has suggested filling the data structure out so that this does not happen.
- raise an exception if the TimeGate comes back with nothing
- create a convenience method for this use case that would handle this error internally
Metadata
Metadata
Assignees
Labels
No labels