Page MenuHomePhabricator

Constraints gadget fails on statements with qualifier/reference results but no mainsnak results
Closed, ResolvedPublic

Description

Berlin (Q64) has an “official name” statement with an “imported from” reference. “official name” (P​1448) has no constraints defined, “imported from” (P​143) does. As a result, the wbcheckconstraints API response for this contains no mainsnak member (there was no MainSnakContext to create it), but does contain a reference member with check results. The gadget currently assumes that a statement result always includes a mainsnak, and therefore fails for this response (TypeError: cannot read property results of undefined).

I’m not sure where we need to fix this. Should the gadget be fixed to cope with this situation? Or should the API be updated to always include a mainsnak, with a potentially empty results array? (And, for consistency, probably the same for qualifiers and references.)

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptOct 13 2017, 12:15 PM
Lucas_Werkmeister_WMDE triaged this task as High priority.Oct 13 2017, 12:15 PM

I discussed this with @Jonas, and for consistency with Wikibase’s JSON format, the mainsnak should always be present (with empty results), but the qualifiers and references may be omitted (Wikibase does that as well).

Change 384060 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/WikibaseQualityConstraints@master] Let gadget cope with missing mainsnaks in response

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

Change 384066 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/WikibaseQualityConstraints@master] Always include main snak context in API response

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

Change 384502 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/WikibaseQualityConstraints@master] Add tests for T178160

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

Change 384066 merged by jenkins-bot:
[mediawiki/extensions/WikibaseQualityConstraints@master] Always include main snak context in API response

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

Change 384502 merged by jenkins-bot:
[mediawiki/extensions/WikibaseQualityConstraints@master] Add tests for T178160

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

Lucas_Werkmeister_WMDE closed this task as Resolved.Oct 19 2017, 5:03 PM

Should be fixed.

Change 384060 abandoned by Lucas Werkmeister (WMDE):
Let gadget cope with missing mainsnaks in response

Reason:
We never backported this, and now the proper fix has been merged and should be deployed soon.

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