Page MenuHomePhabricator

cfd.py throws an error after few seconds
Closed, DeclinedPublicBUG REPORT

Description

Steps to reproduce

$ python pwb.py cfd -lang:en -family:wikipedia -simulate
Robot - Speedily moving category Academics by university in Zimbabwe to [[:Category:Faculty by university in Zimbabwe]] per [[WP:CFDS|CFDS]].
WARNING: The category page target 'Category:Faculty by university in Zimbabwe' already exists.
WARNING: The category talk page target 'Category talk:Faculty by university in Zimbabwe' already exists.
Robot - Speedily moving category Academics by university or college in Uganda to [[:Category:Faculty by university or college in Uganda]] per [[WP:CFDS|CFDS]].

...

WARNING: The category page target 'Category:Kwame Nkrumah University of Science and Technology faculty' already exists.
WARNING: The category talk page target 'Category talk:Kwame Nkrumah University of Science and Technology faculty' already exists.
SIMULATION: wbeditentity action blocked
Traceback (most recent call last):
  File "pwb.py", line 250, in <module>
    if not main():
  File "pwb.py", line 243, in main
    run_python_file(filename, [filename] + args, argvu, file_package)
  File "pwb.py", line 95, in run_python_file
    main_mod.__dict__)
  File "./scripts/cfd.py", line 237, in <module>
    main()
  File "./scripts/cfd.py", line 195, in main
    robot.run()
  File "/home/pavel/pywikibot/scripts/category.py", line 695, in run
    self._update_wikibase_item()
  File "/home/pavel/pywikibot/scripts/category.py", line 842, in _update_wikibase_item
    item.setSitelink(self.newcat, summary=comment)
  File "/home/pavel/pywikibot/pywikibot/page.py", line 4595, in setSitelink
    self.setSitelinks([sitelink], **kwargs)
  File "/home/pavel/pywikibot/pywikibot/page.py", line 4636, in setSitelinks
    self.editEntity(data, **kwargs)
  File "/home/pavel/pywikibot/pywikibot/page.py", line 128, in wrapper
    handle(func, self, *args, **kwargs)
  File "/home/pavel/pywikibot/pywikibot/page.py", line 107, in handle
    func(self, *args, **kwargs)
  File "/home/pavel/pywikibot/pywikibot/page.py", line 4230, in editEntity
    self.latest_revision_id = updates['entity']['lastrevid']
KeyError: 'entity'
CRITICAL: Exiting due to uncaught exception <class 'KeyError'>
$ python pwb.py cfd -lang:en -family:wikipedia
Robot - Speedily moving category Academics by university in Zimbabwe to [[:Category:Faculty by university in Zimbabwe]] per [[WP:CFDS|CFDS]].
WARNING: The category page target 'Category:Faculty by university in Zimbabwe' already exists.
WARNING: The category talk page target 'Category talk:Faculty by university in Zimbabwe' already exists.
Robot - Speedily moving category Academics by university or college in Uganda to [[:Category:Faculty by university or college in Uganda]] per [[WP:CFDS|CFDS]].

...

WARNING: The category page target 'Category:Kwame Nkrumah University of Science and Technology faculty' already exists.
WARNING: The category talk page target 'Category talk:Kwame Nkrumah University of Science and Technology faculty' already exists.
WARNING: API error failed-save: The save has failed.
Traceback (most recent call last):
  File "/home/pavel/pywikibot/pywikibot/page.py", line 107, in handle
    func(self, *args, **kwargs)
  File "/home/pavel/pywikibot/pywikibot/page.py", line 4229, in editEntity
    baserevid=baserevid, **kwargs)
  File "/home/pavel/pywikibot/pywikibot/tools/__init__.py", line 1738, in wrapper
    return obj(*__args, **__kw)
  File "/home/pavel/pywikibot/pywikibot/site.py", line 1320, in callee
    return fn(self, *args, **kwargs)
  File "/home/pavel/pywikibot/pywikibot/site.py", line 7856, in editEntity
    data = req.submit()
  File "/home/pavel/pywikibot/pywikibot/data/api.py", line 2079, in submit
    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-announce mailing list at &lt;https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce&gt; for notice of API deprecations and breaking changes.]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "pwb.py", line 250, in <module>
    if not main():
  File "pwb.py", line 243, in main
    run_python_file(filename, [filename] + args, argvu, file_package)
  File "pwb.py", line 95, in run_python_file
    main_mod.__dict__)
  File "./scripts/cfd.py", line 237, in <module>
    main()
  File "./scripts/cfd.py", line 195, in main
    robot.run()
  File "/home/pavel/pywikibot/scripts/category.py", line 695, in run
    self._update_wikibase_item()
  File "/home/pavel/pywikibot/scripts/category.py", line 842, in _update_wikibase_item
    item.setSitelink(self.newcat, summary=comment)
  File "/home/pavel/pywikibot/pywikibot/page.py", line 4595, in setSitelink
    self.setSitelinks([sitelink], **kwargs)
  File "/home/pavel/pywikibot/pywikibot/page.py", line 4636, in setSitelinks
    self.editEntity(data, **kwargs)
  File "/home/pavel/pywikibot/pywikibot/page.py", line 128, in wrapper
    handle(func, self, *args, **kwargs)
  File "/home/pavel/pywikibot/pywikibot/page.py", line 120, in handle
    raise pywikibot.OtherPageSaveError(self, err)
pywikibot.exceptions.OtherPageSaveError: Edit to page [[wikidata:Q8219034]] 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.]
CRITICAL: Exiting due to uncaught exception <class 'pywikibot.exceptions.OtherPageSaveError'>

Event Timeline

Xqt triaged this task as High priority.May 14 2019, 10:05 AM

First issue similar to T76694 and T129866 (perhaps duplicite?)

Second issue similar to T168575 and T192912

Xqt changed the subtype of this task from "Task" to "Bug Report".May 14 2019, 1:53 PM
JJMC89 subscribed.

If there are issues in a script, it would be in category.py. I don't think the first issue is in a script: T76694: Wikibase operations fail when -simulate enabled.

The second issue is occurring because the account you are using cannot move categories on enwiki, so _update_wikibase_item() is called. I don't know what causes the wikibase errors, but it isn't coming from cfd.py or category.py.

It should at least mention, that I don't have rights to use the script, not throw Wikibase error... (seems like T71283)

It should at least mention, that I don't have rights to use the script, not throw Wikibase error... (seems like T71283)

You should be able to use the script even if you cannot move categories. When the user cannot move a category, the script does it by copying the category's text from the old to the new (_movecat()) and manually updating the wikibase item (_update_wikibase_item()). item.setSitelink is what is failing, but I don't know why. (I've never worked with wikibase.)

I see. Thank you for the explanation. This is also how it works on cswiki, but here we don't need a script as that one category per week can be easily tracked. Basically category.py works quite well here if really needed.

Xqt subscribed.

cfd.py is archived