Page MenuHomePhabricator

WikibasePage.editEntity fails with KeyError after null edit
Closed, DuplicatePublic

Description

C:\pwb\GIT\core>pwb.py interwikidata -simulate -page:"Der Dibbuk" -lang:de -family:wikipedia
Retrieving 1 pages from wikipedia:de.


>>> Der Dibbuk <<<
Adding link to Q2915504
SIMULATION: wbeditentity action blocked.

0 pages read
0 pages written
Execution time: 11 seconds
Script terminated by exception:

ERROR: KeyError: u'entity'
Traceback (most recent call last):
  File "C:\pwb\GIT\core\pwb.py", line 256, in <module>
    if not main():
  File "C:\pwb\GIT\core\pwb.py", line 250, in main
    run_python_file(filename, [filename] + args, argvu, file_package)
  File "C:\pwb\GIT\core\pwb.py", line 121, in run_python_file
    main_mod.__dict__)
  File ".\scripts\interwikidata.py", line 215, in <module>
    main()
  File ".\scripts\interwikidata.py", line 208, in main
    bot.run()
  File "C:\pwb\GIT\core\pywikibot\bot.py", line 1408, in run
    self.treat(page)
  File "C:\pwb\GIT\core\pywikibot\bot.py", line 1695, in treat
    super(ExistingPageBot, self).treat(page)
  File "C:\pwb\GIT\core\pywikibot\bot.py", line 1622, in treat
    self.treat_page()
  File ".\scripts\interwikidata.py", line 91, in treat_page
    item = self.try_to_add()
  File ".\scripts\interwikidata.py", line 170, in try_to_add
    item.setSitelink(self.current_page)
  File "C:\pwb\GIT\core\pywikibot\page.py", line 3953, in setSitelink
    self.setSitelinks([sitelink], **kwargs)
  File "C:\pwb\GIT\core\pywikibot\page.py", line 3994, in setSitelinks
    self.editEntity(data, **kwargs)
  File "C:\pwb\GIT\core\pywikibot\page.py", line 3684, in editEntity
    self.latest_revision_id = updates['entity']['lastrevid']
KeyError: u'entity'
<type 'exceptions.KeyError'>
CRITICAL: Closing network session.

C:\pwb\GIT\core>

content of updates is:

{u'wbeditentity': {u'nochange': u'', u'result': u'Success'}}

Event Timeline

Xqt created this task.Mar 14 2016, 3:06 PM
Restricted Application added subscribers: pywikibot-bugs-list, Aklapper. · View Herald TranscriptMar 14 2016, 3:06 PM
Xqt triaged this task as Normal priority.Mar 14 2016, 3:06 PM

Just skip the updates when 'nochange' is in 'wbeditentity'?

Ricordisamoa renamed this task from Page.EditEntity fails with KeyError to WikibasePage.editEntity fails with KeyError after null edit.Mar 15 2016, 3:39 AM
Xqt added a comment.Mar 15 2016, 10:31 AM

I am really unsure whether 'entity' is the right key at all. I found always 'item' as a key. Maybe it has been changed?
Refer https://www.mediawiki.org/wiki/Wikibase/API#wbeditentity

I am really unsure whether 'entity' is the right key at all. I found always 'item' as a key. Maybe it has been changed?
Refer https://www.mediawiki.org/wiki/Wikibase/API#wbeditentity

The wiki documentation is wrong. 'entity' is right.

Restricted Application added a subscriber: TerraCodes. · View Herald TranscriptFeb 22 2017, 8:51 PM
Restricted Application added a subscriber: Liuxinyu970226. · View Herald TranscriptMay 18 2019, 8:56 PM