Page MenuHomePhabricator

Missing 'reference' key when trying to addSources
Closed, ResolvedPublicBUG REPORT

Description

List of steps to reproduce (step by step, including full links if applicable):
pwb dataextend -simulate Q42

What happens?:

Found here:
VIAF ID: 171149066383365600907
date of birth: 1952
date of death: 2001
ISNI: 0000 0000 8045 6315
Save this? (Y/n) y

Adding VIAF ID: 171149066383365600907
SIMULATION: wbsetclaim action blocked.
Sourcing VIAF ID: 171149066383365600907
SIMULATION: wbsetreference action blocked.

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

ERROR: KeyError: 'reference'
Traceback (most recent call last):
  File "C:\pwb\GIT\core\pwb.py", line 499, in <module>
    main()
  File "C:\pwb\GIT\core\pwb.py", line 483, in main
    if not execute():
  File "C:\pwb\GIT\core\pwb.py", line 466, in execute
    run_python_file(filename, script_args, module)
  File "C:\pwb\GIT\core\pwb.py", line 143, in run_python_file
    exec(compile(source, filename, 'exec', dont_inherit=True),
  File ".\scripts\dataextend.py", line 15458, in <module>
    main()
  File ".\scripts\dataextend.py", line 15454, in main
    bot.run()
  File "C:\pwb\GIT\core\pywikibot\bot.py", line 1571, in run
    self.treat(page)
  File ".\scripts\dataextend.py", line 999, in treat
    createdclaim.addSources(
  File "C:\pwb\GIT\core\pywikibot\page\_wikibase.py", line 1706, in addSources
    claim.hash = data['reference']['hash']
KeyError: 'reference'
CRITICAL: Exiting due to uncaught exception <class 'KeyError'>

C:\pwb\GIT\core>

The following sourcedata is tried to be used with addSources:

[Claim.fromJSON(DataSite("wikidata", "wikidata"), {'mainsnak': {'snaktype': 'value', 'property': 'P854', 'datatype': 'url', 'datavalue': {'value': 'https://authority.bibsys.no/authority/rest/authorities/html/90196888', 'type': 'string'}}, 'type': 'statement', 'rank': 'normal'}), 
 Claim.fromJSON(DataSite("wikidata", "wikidata"), {'mainsnak': {'snaktype': 'value', 'property': 'P1015', 'datatype': 'external-id', 'datavalue': {'value': '90196888', 'type': 'string'}}, 'type': 'statement', 'rank': 'normal'}),
 Claim.fromJSON(DataSite("wikidata", "wikidata"), {'mainsnak': {'snaktype': 'value', 'property': 'P813', 'datatype': 'time', 'datavalue': {'value': {'time': '+00000002022-04-12T00:00:00Z', 'precision': 11, 'after': 0, 'before': 0, 'timezone': 0, 'calendarmodel': 'http://www.wikidata.org/entity/Q1985727'}, 'type': 'time'}}, 'type': 'statement', 'rank': 'normal'})]

Software version:
Pywikibot 7.2 with this patch
see also: rPWBC8a435798

Event Timeline

Xqt triaged this task as Medium priority.Apr 12 2022, 10:27 AM
Xqt updated the task description. (Show Details)
Xqt updated the task description. (Show Details)
SIMULATION: wbsetreference action blocked.

I think this is the problem. If there is a fake response, it doesn't have data that the real server would send. (T76694)

SIMULATION: wbsetreference action blocked.

I think this is the problem. If there is a fake response, it doesn't have data that the real server would send. (T76694)

Ah, good catch!

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

[pywikibot/core@master] [bugfix] Expand simulate query result

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

Save this? (Y/n) y
Adding VIAF ID: 171149066383365600907
SIMULATION: wbsetclaim action blocked.
Sourcing VIAF ID: 171149066383365600907
SIMULATION: wbsetreference action blocked.
Adding date of birth: 1952
SIMULATION: wbsetclaim action blocked.
Sourcing date of birth: 1952
SIMULATION: wbsetreference action blocked.
Adding date of death: 2001
SIMULATION: wbsetclaim action blocked.
Sourcing date of death: 2001
SIMULATION: wbsetreference action blocked.
Sourcing ISNI: 0000 0000 8045 6315
SIMULATION: wbsetreference action blocked.

New names found:

Change 779453 merged by jenkins-bot:

[pywikibot/core@master] [bugfix] Expand simulate query result

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