Page MenuHomePhabricator

Make Pywikibot not crash on new item creation bug
Closed, ResolvedPublic


See . Everyone once in a while you'll get an apierror when trying to create a new page:

File "C:\pywikibot\core\pywikibot\", line 2523, in editEntity
  baserevid=baserevid, **kwargs)
File "C:\pywikibot\core\pywikibot\", line 721, in callee
  return fn(self, *args, **kwargs)
File "C:\pywikibot\core\pywikibot\", line 3725, in editEntity
  data = req.submit()
File "C:\pywikibot\core\pywikibot\data\", line 401, in submit
  raise APIError(code, info, **result["error"]) failed-save: Could not create a new page.
It already exists.
<class ''>

Error should be caught somewhere in the lower layers and it should be retried (just like with connection problems). It should respect maxretries so it doesn't get stuck in a loop

Version: core-(2.0)
Severity: critical
See Also:



Event Timeline

bzimport raised the priority of this task from to Needs Triage.Nov 22 2014, 2:51 AM
bzimport set Reference to bz62126.
bzimport added a subscriber: Unknown Object (????).

Change 116280 had a related patch set uploaded by Xqt:
(bug 62126) Retry creating a new page at wikidata.

Change 116280 merged by jenkins-bot:
(bug 62126) Retry creating a new page at wikidata.

I think this bug should only force a retry if the reason the save failed is 'edit-already-exists'

i.e. pseudocode

-if code == "failed-save" and action == 'wbeditentity':
+if code == "failed-save" and action == 'wbeditentity' and info == 'Could not create a new page.\nIt already exists.':


-if code == "failed-save" and action == 'wbeditentity':
+if code == "failed-save" and action == 'wbeditentity':
+ messages = result["error"].pop("messages", None)
+ if messages and messages['0'] and messages['0']['name'] == 'edit-already-exists':

The error message is 'wikibase-error-label-not-unique-item'

See also

The error we should not resubmit is 'wikibase-error-label-not-unique-item'.

The only error we should retry is 'edit-already-exists'.

That code and my pseudo-code above do the same thing, in different ways.