Page MenuHomePhabricator

Invalid qualifier snak in Form preventing correct JSON serialization and editing
Open, Needs TriagePublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

What happens?:

{
    "snaktype": "value",
    "property": "P898",
    "hash": "e49ad5fcdc05da78bac23b8373d04a80fecf16aa",
    "datavalue": {
        "value": null,
        "type": "string",
        "error": "Can only construct StringValue from strings"
    },
    "datatype": "string"
}
  • In my browser's console, I see an error:
Error: The undeserializable structure has to be a plain object.
    UnDeserializableValue UnDeserializableValue.js:29
    createFunction util.inherit.js:37
    deserialize SnakDeserializer.js:38
    addSerializedSnaksToSnakList SnakListDeserializer.js:17
    deserialize SnakListDeserializer.js:76
    deserialize ClaimDeserializer.js:31
    deserialize StatementDeserializer.js:25
    deserialize StatementListDeserializer.js:28

What should have happened instead?:

None of those errors.

Software version (skip for WMF-hosted wikis like Wikipedia): Wikidata, in production

Other information (browser name/version, screenshots, etc.):

image.png (339×939 px, 35 KB)

Event Timeline

In the JSON serialization of the entity (https://www.wikidata.org/w/api.php?action=wbgetentities&ids=L1259271), I see the serialization of the qualifier as:

Apparently that’s how it was saved internally too? o_O

$ curl -s 'https://www.wikidata.org/w/api.php?action=query&revids=2081476901&prop=revisions&rvprop=content&rvslots=main&format=json&formatversion=2' | jq '.query.pages[0].revisions[0].slots.main.content | fromjson | .forms[0].claims.P7243[0].qualifiers.P898[0]'
{
  "snaktype": "value",
  "property": "P898",
  "hash": "e49ad5fcdc05da78bac23b8373d04a80fecf16aa",
  "datavalue": {
    "value": null,
    "type": "string",
    "error": "Can only construct StringValue from strings"
  }
}
lucaswerkmeister-wmde@mwdebug2002:~$ mwscript getText wikidatawiki Lexeme:L1259271 | jq '.forms[0].claims.P7243[0].qualifiers.P898[0]'
{
  "snaktype": "value",
  "property": "P898",
  "hash": "e49ad5fcdc05da78bac23b8373d04a80fecf16aa",
  "datavalue": {
    "value": null,
    "type": "string",
    "error": "Can only construct StringValue from strings"
  }
}

Edit: And just to be absolutely sure that this doesn’t come from the content handler, I checked the blob store directly – same thing:

lucaswerkmeister-wmde@mwdebug2002:~$ mwscript shell wikidatawiki
Psy Shell v0.12.0 (PHP 7.4.33 — cli) by Justin Hileman
> json_decode(MediaWiki\MediaWikiServices::getInstance()->getBlobStore()->getBlob('tt:2108865247'))->forms[0]->claims->P7243[0]->qualifiers->P898[0]
= {#6449
    +"snaktype": "value",
    +"property": "P898",
    +"hash": "e49ad5fcdc05da78bac23b8373d04a80fecf16aa",
    +"datavalue": {#6450
      +"value": null,
      +"type": "string",
      +"error": "Can only construct StringValue from strings",
    },
  }

Previously reported at https://www.wikidata.org/wiki/Wikidata_talk:Lexicographical_data#Broken_lexeme (though without much detail). @Infovarius: It would be good to know what data you sent to the API to create this lexeme.

By the way, my guess would be that it’s still possible to edit the lexeme via the API (e.g. remove that qualifier, or even the whole statement, via the API sandbox), but I’m not sure if I should try it out myself.