Page MenuHomePhabricator

wbgetentities API returns useless (at least useless in XML) "missing" attribute for missing entities
Closed, ResolvedPublic

Description

When requesting entities via wbgetentities API module, requested entities which are not in the system will still be taken into the result set with a "missing" attribute. In xml this will look like:

<entities><entity missing="" /></entities>

in JSON:

"entities": { "p1311": { "missing": "" } }

So in the JSON version you can actually still see which entity is missing, in XML you can't.

I would simply suggest taking those references to missing entities entirely out of the result set since the requester can simply check whether all requested entities are actually in the result.
Those "special" entries just make it necessary to differentiate between "real" entity data and other information which requires more additional code.


Version: unspecified
Severity: normal
See Also:
https://bugzilla.wikimedia.org/show_bug.cgi?id=68251

Details

Reference
bz45509

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 22 2014, 1:32 AM
bzimport set Reference to bz45509.
bzimport added a subscriber: Unknown Object (MLST).

I think a better solution here would be to simply add the id into the missing="" tag. Compare the wbgetentities output with the standard API one:

https://www.wikidata.org/w/api.php?action=wbgetentities&ids=Q12324283476384&format=xmlfm

<api success="1">

<entities>
  <entity missing="" />
</entities>

</api>

https://en.wikipedia.org/w/api.php?action=query&prop=info&titles=Asljdhfksdjhfksdjfh

<api>

<query>
  <pages>
    <page ns="0" title="Asljdhfksdjhfksdjfh" missing="" contentmodel="wikitext" pagelanguage="en" />
  </pages>
</query>

</api>

The "missing" tag should always be there, along with any other details we may have (that is, usually, either site and title or the id). The key for the missing entry may or may not be a negative number - in case a lookup by ID failed, the key should be the requested id, for convenient lookup.

Change 150790 had a related patch set uploaded by Daniel Kinzler:
Allow explicit keys for entities in API results.

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

The patch linked above isn't sufficient to fix this, but together with Ic5c4d211df, that should do it. To verify, request a non-existing item by id and ask for xml output. It should then contain <entity id="Q1245" missing="" />.

Change 150790 merged by jenkins-bot:
Allow explicit keys for entities in API results.

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