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

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

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