Page MenuHomePhabricator

Call to the Wikibase API for entity types that are not enabled it should been handled gracefully, not surface as an exception
Open, Needs TriagePublic

Description

As discovered in T217285.

On wiki which does not provide/does not have properties enabled, request to Wikibase APIs using Property ID as an input result in exceptions

E.g.
https://commons.wikimedia.org/w/api.php?action=wbgetentities&ids=P17

{
    "error": {
        "code": "internal_api_error_Wikibase\\DataModel\\Services\\Lookup\\EntityLookupException",
        "info": "[XH57EwpAMDoAAIeh@bsAAADC] Caught exception of type Wikibase\\DataModel\\Services\\Lookup\\EntityLookupException",
        "errorclass": "Wikibase\\DataModel\\Services\\Lookup\\EntityLookupException"
    },
    "servedby": "mw1223"
}

https://commons.wikimedia.org/w/api.php?action=wbgetclaims&entity=Q42&property=P31

{
    "error": {
        "code": "internal_api_error_Wikibase\\DataModel\\Services\\Lookup\\EntityLookupException",
        "info": "[XH57FQpAAEcAAF5wpJoAAAAI] Caught exception of type Wikibase\\DataModel\\Services\\Lookup\\EntityLookupException",
        "errorclass": "Wikibase\\DataModel\\Services\\Lookup\\EntityLookupException"
    },
    "servedby": "mw1276"
}

I've did a little look into the issue, find my finding below

Background:
Entity types can be "defined" (vocabulary mine, not something settled in Wikibase language I believe), i.e. the software will now how the Property ID look like, what kind of internal fields Property has, etc.
Property being does not mean Wikibase instance actually stores any of them (e.g. in case of WikibaseLexeme extension, wiki might not be storing any lexemes, but have the extension load to understand L123 is not a dummy string but the ID) , or use Properties stores in some other wiki (federation) but that other wiki is not yet configured (a bit of a special case, but it is the case now in the case of Commons). In other words, Properties are "defined" but are not "enabled".

Issue:
When processing the input, API recognizes P123 as the Property ID ("defined"). As the wiki does not have Properties "enabled", attempt to load the property data from the database fails (in cases covered here it comes down to not defined namespace ID of property pages).

Random thought: one option to deal with these is to not only check if the input ID is the ID of "defined" type, but actually the one of the "enabled" type.
I.e.to make API implementation aware of what entity types are enabled at the of API request.