Sometimes mw.wikibase.getReferencedEntityId() calls unexpectedly fail. For instance, a single
mw.wikibase.getReferencedEntityId( 'Q637739', 'P31', { 'Q7397', 'Q2095', 'Q55488' } )
call gives the German result
Lua-Fehler: Zu viele Aufrufe von „mw.wikibase.getReferencedEntityId“, nur bis zu 3 sind erlaubt.
(Too many mw.wikibase.getReferencedEntityId calls. Only three are allowed.)
I do not know what happened because it is only a single call, and there are only three P31 values. What can be done to prevent or to catch this error message?
This function restriction is not documented in the Wikibase documentation at https://www.mediawiki.org/wiki/Extension:Wikibase_Client/Lua.