Page MenuHomePhabricator

WikidataBot: Never write to wikidata:-1
Closed, ResolvedPublic

Description

Reproduce: python harvest_template.py -lang:en -template:"Sockpuppet" -namespace:2 -create 1 P370 (This is only an example to reproduce the bug; no new items will be created as they will be stopped by abusefilter)

Result: When creation of an item is failed wikidata:-1 will returned; the bot will try to add statements to wikidata:-1 and pywikibot.exceptions.OtherPageSaveError will be throwed which make the bot crash

Expected: If an item can not be created due to network error or rate limit, retry creation after some time. Otherwise (e.g. stopped by abusefilter), skip the current page and proceed the next one.

Related Objects

Event Timeline

If an item can not be created due to network error or rate limit, retry creation after some time.

Does (not) Pywikibot support this? If not, the support should be made for the whole framework.

Otherwise (e.g. stopped by abusefilter), skip the current page and proceed the next one.

Single-line fix.

Change 445885 had a related patch set uploaded (by Matěj Suchánek; owner: Matěj Suchánek):
[pywikibot/core@master] Don't let the bot crash when new item is blocked

https://gerrit.wikimedia.org/r/445885

the bot will try to add statements to wikidata:-1

Fortunately, this isn't truth:

ERROR: OtherPageSaveError: Edit to page [[wikidata:-1]] failed:
failed-save: The save has failed. [help:See https://www.wikidata.org/w/api.php f
or API usage. Subscribe to the mediawiki-api-announce mailing list at <https:
//lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce> for notice of
API deprecations and breaking changes.]
Traceback (most recent call last):
  File "C:\Users\admin\Documents\core\pywikibot\page.py", line 109, in handle
    func(self, *args, **kwargs)
  File "C:\Users\admin\Documents\core\pywikibot\page.py", line 4175, in editEnti
ty
    baserevid=baserevid, **kwargs)
  File "C:\Users\admin\Documents\core\pywikibot\site.py", line 1317, in callee
    return fn(self, *args, **kwargs)
  File "C:\Users\admin\Documents\core\pywikibot\site.py", line 7718, in editEnti
ty
    data = req.submit()
  File "C:\Users\admin\Documents\core\pywikibot\data\api.py", line 2217, in subm
it
    raise APIError(**result['error'])
pywikibot.data.api.APIError: failed-save: The save has failed. [help:See https:/
/www.wikidata.org/w/api.php for API usage. Subscribe to the mediawiki-api-announ
ce mailing list at <https://lists.wikimedia.org/mailman/listinfo/mediawiki-ap
i-announce> for notice of API deprecations and breaking changes.]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\admin\Documents\core\pwb.py", line 253, in <module>
    if not main():
  File "C:\Users\admin\Documents\core\pwb.py", line 246, in main
    run_python_file(filename, [filename] + args, argvu, file_package)
  File "C:\Users\admin\Documents\core\pwb.py", line 115, in run_python_file
    main_mod.__dict__)
  File ".\scripts\harvest_template.py", line 389, in <module>
    main()
  File ".\scripts\harvest_template.py", line 385, in main
    bot.run()
  File "C:\Users\admin\Documents\core\pywikibot\bot.py", line 1598, in run
    super(Bot, self).run()
  File "C:\Users\admin\Documents\core\pywikibot\bot.py", line 1505, in run
    self.treat(page)
  File "C:\Users\admin\Documents\core\pywikibot\bot.py", line 1733, in treat
    self.treat_page()
  File "C:\Users\admin\Documents\core\pywikibot\bot.py", line 2184, in treat_page
    item = self.create_item_for_page(page, asynchronous=False)
  File "C:\Users\admin\Documents\core\pywikibot\bot.py", line 2143, in create_item_for_page
    result = self.user_edit_entity(item, data, summary=summary, **kwargs)
  File "C:\Users\admin\Documents\core\pywikibot\bot.py", line 1978, in user_edit_entity
    return self._save_page(item, item.editEntity, data, **kwargs)
  File "C:\Users\admin\Documents\core\pywikibot\bot.py", line 1339, in _save_page
    func(*args, **kwargs)
  File "C:\Users\admin\Documents\core\pywikibot\page.py", line 127, in wrapper
    handle(func, self, *args, **kwargs)
  File "C:\Users\admin\Documents\core\pywikibot\page.py", line 119, in handle
    raise pywikibot.OtherPageSaveError(self, err)
pywikibot.exceptions.OtherPageSaveError: Edit to page [[wikidata:-1]] failed:
failed-save: The save has failed. [help:See https://www.wikidata.org/w/api.php for API usage. Subscribe to the mediawiki-api-announce mailing list at &lt;https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce&gt; for notice of API deprecations and breaking changes.]
Dropped throttle(s).
<class 'pywikibot.exceptions.OtherPageSaveError'>
CRITICAL: Closing network session.
Network session closed.
Xqt claimed this task.
Xqt reassigned this task from Xqt to matej_suchanek.
Xqt subscribed.

Change 445885 merged by jenkins-bot:
[pywikibot/core@master] Don't let WikidataBot crash on save related errors

https://gerrit.wikimedia.org/r/445885