Page MenuHomePhabricator

Pywikibot crashing on ratelimit after the ratelimit removal from bot group in 2020
Closed, ResolvedPublicBUG REPORT

Description

I noticed I got:
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-announce mailing list at <https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce> for notice of API deprecations and breaking changes.;
messages: [{'name': 'wikibase-api-failed-save', 'html': {'*': 'The save has failed.'}, 'parameters': []}, {'name': 'actionthrottledtext', 'html': {'*': 'As an anti-abuse measure, you are limited from performing this action too many times in a short space of time, and you have exceeded this limit.\nPlease try again in a few minutes.'}, 'parameters': []}]]
CRITICAL: Exiting due to uncaught exception <class 'pywikibot.data.api.APIError'>

I just assume this is because of T258354

I run the latest version
Pywikibot: [ssh] pywikibot-core.git (fed71d9, g13736, 2020/11/23, 11:03:20, master)
Release version: 5.2.0.dev0

I assumed that this was already handled based on T192912 and T253180 where @Xqt patched up Pywikibot to handle these cases

Event Timeline

Looks like it is the same as T192912

Due to

if code == 'failed-save' and \
   self.action == 'wbeditentity' and \
   self._is_wikibase_error_retryable(result['error']):
    self.wait()
    continue

it seems that action is not 'wbeditentity'; any idea what it was?

See also rPWBC5d636a8a4d5d66d434

Xqt triaged this task as High priority.Nov 24 2020, 5:35 PM

Looks like it is the same as T192912

Due to

if code == 'failed-save' and \
   self.action == 'wbeditentity' and \
   self._is_wikibase_error_retryable(result['error']):
    self.wait()
    continue

it seems that action is not 'wbeditentity'; any idea what it was?

Either https://www.wikidata.org/w/api.php?action=help&recursivesubmodules=1#wbcreateclaim or https://www.wikidata.org/w/api.php?action=help&recursivesubmodules=1#wbsetqualifier I think.
We have a whole list of possible Wikibase actions that trigger a write. If I look at self.write = self.action in {....] that seems to be quite complete. Maybe in the start of the init define a list of normal write actions and a list of wbwrite actions and update both checks to use these lists? First check would use both lists and the code you pasted the wikibase list.

Referring the first patch mentioned above I think wbeditentity action is related to the first error name but not valid for actionthrottledtext. This should always cause a wait cycle.

According to this test, there are several actions that might emit 'wikibase-api-failed-save' as message.
https://github.com/wikimedia/Wikibase/blob/e388e5b69ee0487566d7a8a77196ac0056f49747/repo/tests/phpunit/includes/Api/ApiUserBlockedTest.php

The test seems to be for blocked users, but maybe the message is used elsewhere as well.
Shouldn't they be all checked in:

if code == 'failed-save' and \
   self.action == 'wbeditentity' and \
   self._is_wikibase_error_retryable(result['error']):
    self.wait()
    continue

instead of 'wbeditentity' only?

Change 643491 had a related patch set uploaded (by Xqt; owner: Xqt):
[pywikibot/core@master] [bugfix] _is_wikibase_error_retryable rewritten

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

Xqt changed the subtype of this task from "Task" to "Bug Report".Dec 5 2020, 12:41 PM

Change 643491 merged by jenkins-bot:
[pywikibot/core@master] [bugfix] _is_wikibase_error_retryable rewritten

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