In Lua, mw.wikibase.getEntity(id) will return a entity object if "id" is a valid Wikidata entity id, e.g. 'Q42'. However, if the id isn't valid (e.g. 'Q42000000000000000000000000000') it results in a big red Lua error message "The ID entered is unknown to the system. Please use a valid entity ID." This happens even if pcall() or xpcall() is used.
Actual results/demonstartion: See mw:Extension talk:Wikibase Client/Lua § testing for a valid QID ? (permalink to lua code in Module:Sandbox)
Expected results: One or more of the following:
- mw.wikibase.getEntity(invalid_id) retuns nil
- pcall() and/or xpcall() catch the error, and behave as one would expect
- another function, perhaps named mw.wikibase.checkEntity(id), that returns true if the id is valid, or false if the id is invalid
- some other way of determining validity without actually throwing an error