Page MenuHomePhabricator

Wikibase operations fail when -simulate enabled
Closed, ResolvedPublicBUG REPORT

Description

Similar errors occur in addClaim, addSource, etc .. but here is the backtrace for editEntity updating an item.

Welcome to the Pywikibot interactive shell!
>>> import pywikibot
>>> datasite = pywikibot.site.DataSite('test', 'wikidata', None, None)
>>> item = pywikibot.page.ItemPage(datasite, 'Q68')
>>> item.get()
Found 4 wikidata:test processes running, including this one.
{'claims': {u'P115': [<pywikibot.page.Claim instance at 0xb611b5ac>]}, 'labels': {u'en': u'Test123'}, 'sitelinks': {}, 'descriptions': {}, 'aliases': {u'en': [u'1417625792.03']}}
>>> item.editEntity(data=item.toJSON())
Logging in to wikidata:test as JVbot
Should be logged in now
SIMULATION: wbeditentity action blocked.
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File ".../pywikibot/page.py", line 3035, in editEntity
    self.lastrevid = updates['entity']['lastrevid']
KeyError: 'entity'

Event Timeline

jayvdb raised the priority of this task from to Needs Triage.
jayvdb updated the task description. (Show Details)
jayvdb added a project: Pywikibot-Wikidata.
jayvdb changed Security from none to None.
jayvdb subscribed.
Xqt triaged this task as High priority.Nov 6 2018, 6:56 AM
Xqt changed the subtype of this task from "Task" to "Bug Report".Jun 24 2020, 11:52 AM
Xqt added a subscriber: matej_suchanek.

Update traceback as follows:

>>> import pwb, pywikibot
>>> datasite = pywikibot.site.DataSite('test', 'wikidata', None)
>>> item = pywikibot.page.ItemPage(datasite, 'Q68')
>>> item.get()
{'labels': <pywikibot.page.LanguageDict object at 0x00000185034F6FD0>, 'descriptions': <pywikibot.page.LanguageDict object at 0x00000185034F6F70>, 'aliases': <pywikibot.page.AliasesDict object at 0x00000185034F6F10>, 'claims': <pywikibot.page.ClaimCollection object at 0x00000185034F6E80>, 'sitelinks': <pywikibot.page.SiteLinkCollection object at 0x00000185034F6EB0>}
>>> pywikibot.config.simulate = False
>>> item.editEntity(data=item.toJSON())
Password for user Xqbot on wikidata:test (no characters will be shown): WARNING: C:\Python38\lib\getpass.py:100: GetPassWarning: Can not control echo on the terminal.
  return fallback_getpass(prompt, stream)

Warning: Password input may be echoed.
*****
Logging in to wikidata:test as Xqbot
>>> item.editEntity(data=item.toJSON())  ## no change is made with simulate=False
Sleeping for 18.8 seconds, 2020-06-24 13:48:21
>>> pywikibot.config.simulate = True
>>> item.editEntity(data=item.toJSON())
SIMULATION: wbeditentity action blocked. ***
Traceback (most recent call last):
  File "<pyshell#44>", line 1, in <module>
    item.editEntity(data=item.toJSON())
  File "C:\pwb\GIT\core\pywikibot\page\__init__.py", line 136, in wrapper
    handle(func, self, *args, **kwargs)
  File "C:\pwb\GIT\core\pywikibot\page\__init__.py", line 115, in handle
    func(self, *args, **kwargs)
  File "C:\pwb\GIT\core\pywikibot\page\__init__.py", line 4547, in editEntity
    super(WikibasePage, self).editEntity(
  File "C:\pwb\GIT\core\pywikibot\page\__init__.py", line 4271, in editEntity
    self._content = updates['entity']
KeyError: 'entity'
>>>

Curiously no change is made with pywikibot.config.simulate = False

Change 697445 had a related patch set uploaded (by Xqt; author: Xqt):

[pywikibot/core@master] [tests] Expand simulate query response

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

Xqt claimed this task.

Change 697445 merged by jenkins-bot:

[pywikibot/core@master] [tests] Expand simulate query response

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