In the present version of Wikidata it is possible to add all kinds of stuff into an item by creating a valid JSON structure and saving it. This could create serious problems with data integrity and consistency.
There are several ways to clean up the structure, and one of the simplest is perhaps to traverse the structure and flag those branches and leafs that can't be somehow validated as legal. Note that the focus should be on letting a legal structure pass after successful tests, and not on failing an illegal one.
Version: unspecified
Severity: normal
See Also:
https://bugzilla.wikimedia.org/show_bug.cgi?id=36431
https://bugzilla.wikimedia.org/show_bug.cgi?id=38234