Page MenuHomePhabricator

Inconsistencies between Wikidata and Structured Data about Snak's "datatype" from wbgetentities API results
Open, Needs TriagePublic

Description

Hello everybody!

I noticed that snaks in Wikimedia Commons' Structured Data may have not the "datatype" attribute.

Example in Wikidata that has the "datatype" attribute:

https://www.wikidata.org/w/api.php?action=wbgetentities&ids=Q1&props=claims

"mainsnak": {
    "snaktype": "value",
    "property": "P793",
    "hash": "46559e43804873b0d843230010c6e9942593b8af",
    "datavalue": {
        "value": {
            "entity-type": "item",
            "numeric-id": 323,
            "id": "Q323"
        },
        "type": "wikibase-entityid"
    },
    "datatype": "wikibase-item"
},

Then an example in Wikimedia Commons where the "datatype" is not provided:

https://commons.wikimedia.org/w/api.php?action=wbgetentities&ids=M70758296&props=claims

"mainsnak": {
    "snaktype": "value",
    "property": "P180",
    "hash": "6f6cd82613d00eb32e7c17e71d116637dbc2635a",
    "datavalue": {
        "value": {
            "entity-type": "item",
            "numeric-id": 55170514,
            "id": "Q55170514"
        },
        "type": "wikibase-entityid"
    }
}

I know that everything is in alpha, but I don't understand if this an undocumented inconsistency between these two Wikibase instances or if this is a transition for a removal of this attribute. Are there some public thoughts about this?

Thank you!

This is somehow related to other inconsistencies found, like this:

T149410: For consistency MediaInfo serialization should use "claims" as key, rather than "statements"

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript
valerio.bozzolan renamed this task from Missing "datatype" from statements returned by wbgetentities in Structured Data to Inconsistence between Wikidata and Structured Data about Snak's "datatype" in wbgetentities.Mar 3 2020, 6:53 PM
valerio.bozzolan updated the task description. (Show Details)
valerio.bozzolan renamed this task from Inconsistence between Wikidata and Structured Data about Snak's "datatype" in wbgetentities to Inconsistencies between Wikidata and Structured Data about Snak's "datatype" from wbgetentities API results.Mar 3 2020, 7:00 PM
valerio.bozzolan updated the task description. (Show Details)

Yes, that "bug" or "feature" cause my c:Module:Wikidata date not to work with SDC entities. The fix was simple bit it took a long time to debug. It would be nice if SDC used the same schema, interface, etc. as Wikidata, so we do not have to be wasting time debugging two almost identical systems.

The "datatype" is missing because Wikibase only adds it to a certain hard-coded list of “paths” in the JSON, and (currently) all of those paths expect "claims", not "statements". (So, yes, this is due to T149410.)

This means that the "datatype" is present in the wbgetclaims response, since that uses the key "claims":

$ curl -s 'https://commons.wikimedia.org/w/api.php?action=wbgetentities&ids=M80857538&format=json&formatversion=2' | jq .entities.M80857538.statements.P180[0].mainsnak
{
  "snaktype": "value",
  "property": "P180",
  "hash": "a15d400991061ac3ac583f46991b86f59d7d00af",
  "datavalue": {
    "value": {
      "entity-type": "item",
      "numeric-id": 1426529,
      "id": "Q1426529"
    },
    "type": "wikibase-entityid"
  }
}
$ curl -s 'https://commons.wikimedia.org/w/api.php?action=wbgetclaims&entity=M80857538&format=json&formatversion=2' | jq .claims.P180[0].mainsnak
{
  "snaktype": "value",
  "property": "P180",
  "hash": "a15d400991061ac3ac583f46991b86f59d7d00af",
  "datavalue": {
    "value": {
      "entity-type": "item",
      "numeric-id": 1426529,
      "id": "Q1426529"
    },
    "type": "wikibase-entityid"
  },
  "datatype": "wikibase-item"
}

The "datatype" is also currently included in the wbeditentity response, though that will change with T271105 unless we add extra code to keep it.