Wikidata / Wikidata-Toolkit

Java library to interact with Wikibase
https://www.mediawiki.org/wiki/Wikidata_Toolkit
Apache License 2.0
373 stars 100 forks source link

JSON deserialization error in RdfSerializationExample #848

Open wetneb opened 7 months ago

wetneb commented 7 months ago

Running mvn exec:java -Dexec.mainClass="examples.RdfSerializationExample" in Wikidata-Toolkit-Examples, I get:

2024-02-28 08:49:15 ERROR - Error when reading JSON for entity: Cannot construct instance of `org.wikidata.wdtk.datamodel.implementation.StringValueImpl`, problem: A string value must provide a non-null string
 at [Source: UNKNOWN; byte offset: #UNKNOWN] (through reference chain: java.util.ArrayList[0]->org.wikidata.wdtk.datamodel.implementation.FormDocumentImpl["claims"]->java.util.LinkedHashMap["P7243"]->java.util.ArrayList[0]->org.wikidata.wdtk.datamodel.implementation.StatementImpl$PreStatement["qualifiers"]->java.util.LinkedHashMap["P898"]->java.util.ArrayList[0]->org.wikidata.wdtk.datamodel.implementation.ValueSnakImpl["datavalue"])

This is due to the following lexeme which has an invalid IPA transcription: https://www.wikidata.org/wiki/Lexeme:L1259271

Arguably that's a Wikibase bug: https://phabricator.wikimedia.org/T358644 But it could be worth making sure we don't choke on such JSON serializations, if they can happen.

{
    "snaktype": "value",
    "property": "P898",
    "hash": "e49ad5fcdc05da78bac23b8373d04a80fecf16aa",
    "datavalue": {
        "value": null,
        "type": "string",
        "error": "Can only construct StringValue from strings"
    },
    "datatype": "string"
}