An intermittent problem occurs when a Lua module executes entity = mw.wikibase.getEntity() or its equivalent entity = mw.wikibase.getEntityObject().
The symptom is that a rendered page shows a big red error message saying:
Lua error in mw.wikibase.entity.lua at line 34: The entity data must be a table obtained via mw.wikibase.getEntityObject
and the page is added to Category:Pages_with_script_errors (or local equivalent).
The problem goes away when the page is purged so a link to a demonstration only works for a limited period. Currently, these pages show the error:
Using Special:Search for mw.wikibase.getEntityObject shows lots of cached examples:
Google search also shows examples. For example, search for one of the following then view Google's cache:
"error in mw.wikibase.entity.lua" site:commons.wikimedia.org "error in mw.wikibase.entity.lua" site:en.wikipedia.org "error in mw.wikibase.entity.lua" site:zh.wikipedia.org
The problem occurs when a Lua module uses Wikidata. That calls mw.wikibase.getEntity which calls php.getEntityId. I guess that sometimes times out when it tries to establish a network connection with the Wikidata database.
There was a discussion at enwiki.