Page MenuHomePhabricator

claimit.py crashes after couple of pages "The statement has already a reference with hash"
Open, HighPublic

Description

C:\pwb>pwb.py claimit "-family:wikisource" "-prefixindex:Bajky" "P31" "q693" "p136" "q693"

after edit 2 or little more pages crashes:

>>> Bajky velkých/Padánky <<<


>>> Q61091224 <<<
Adding P31 --> [[wikidata:Q693]]
Adding P136 --> [[wikidata:Q693]]


>>> Bajky velkých/Ptačí krám <<<


>>> Q61091228 <<<
WARNING: API error modification-failed: The statement has already a reference with hash 4c3755e48059aa4684603912434b5a2d1f450079

126 pages read
8 pages written
0 pages skipped
Execution time: 36 seconds
Read operation time: 0 seconds
Write operation time: 4 seconds
Script terminated by exception:

ERROR: APIError: modification-failed: The statement has already a reference with hash 4c3755e48059aa4684603912434b5a2d1f450079 [messages:[{'name': 'wikibase-api-modification-failed', 'parameters': ['The statement has already a reference with hash 4c3755e48059aa4684603912434b5a2d1f450079'], 'html': {'*': 'The statement has already a reference with hash 4c3755e48059aa4684603912434b5a2d1f450079'}}]; 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.]
Traceback (most recent call last):
  File "C:\pwb\pwb.py", line 298, in <module>
    if not main():
  File "C:\pwb\pwb.py", line 293, in main
    run_python_file(filename, [filename] + args, argvu, file_package)
  File "C:\pwb\pwb.py", line 96, in run_python_file
    main_mod.__dict__)
  File ".\scripts\claimit.py", line 166, in <module>
    main()
  File ".\scripts\claimit.py", line 161, in main
    bot.run()
  File "C:\pwb\pywikibot\bot.py", line 1603, in run
    super(Bot, self).run()
  File "C:\pwb\pywikibot\bot.py", line 1511, in run
    self.treat(page)
  File "C:\pwb\pywikibot\bot.py", line 1738, in treat
    self.treat_page()
  File "C:\pwb\pywikibot\bot.py", line 2194, in treat_page
    self.treat_page_and_item(page, item)
  File ".\scripts\claimit.py", line 98, in treat_page_and_item
    item, claim, self.exists_arg, site)
  File "C:\pwb\pywikibot\bot.py", line 2107, in user_add_claim_unless_exists
    return self.user_add_claim(item, claim, source, **kwargs)
  File "C:\pwb\pywikibot\bot.py", line 2019, in user_add_claim
    claim.addSource(sourceclaim)
  File "C:\pwb\pywikibot\page.py", line 5209, in addSource
    self.addSources([claim], **kwargs)
  File "C:\pwb\pywikibot\page.py", line 5219, in addSources
    data = self.repo.editSource(self, claims, new=True, **kwargs)
  File "C:\pwb\pywikibot\site.py", line 1320, in callee
    return fn(self, *args, **kwargs)
  File "C:\pwb\pywikibot\site.py", line 8008, in editSource
    data = req.submit()
  File "C:\pwb\pywikibot\data\api.py", line 2079, in submit
    raise APIError(**result['error'])
pywikibot.data.api.APIError: modification-failed: The statement has already a reference with hash 4c3755e48059aa4684603912434b5a2d1f450079 [messages:[{'name': 'wikibase-api-modification-failed', 'parameters': ['The statement has already a reference with hash 4c3755e48059aa4684603912434b5a2d1f450079'], 'html': {'*': 'The statement has already a reference with hash 4c3755e48059aa4684603912434b5a2d1f450079'}}]; 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.]
Waiting for 6 pages to be put. Estimated time remaining: 0:00:12
CRITICAL: Exiting due to uncaught exception <class 'pywikibot.data.api.APIError'>

C:\pwb>

Tested on two different computers, one with python 2.7, one with 3.6, the only difference is, python 2.7 crashes earlier.

Event Timeline

Restricted Application added a subscriber: pywikibot-bugs-list. · View Herald Transcript
Xqt triaged this task as High priority.May 24 2019, 12:44 PM
Xqt subscribed.

DataSite doesn't have any error handling in editSource() like in APISite.editpage() currently.

Not sure. I'm now quite surprised to see DataSite.editSource in the traceback, given that all new claims can now be created with references via DataSite.addClaim.