Mustache template evaluation failure for non-existent array indices #55200
Labels
:Core/Infra/Scripting
Scripting abstractions, Painless, and Mustache
Team:Core/Infra
Meta label for core/infra team
triaged
Issue has been looked at, and is being left open
When mustache expression requests an item with a non-existent index from a
Collection
object, anIndexOutOfBoundsException
will be thrown which in turn results in template execution failure.The mustache java library does not support indexing into Collection object. This feature is provided by a custom
CustomReflectionObjectHandler
which wraps aCollection
object inside a specialised map of classCustomReflectionObjectHandler#CollectionMap
. The exception is thrown when checking whether the given index is available in the collection through theMap#containsKey
method, whose implementation is simply trying to retrieve the item at given index. Therefore when the index does not exist, anIndexOutOfBoundsException
will be thrown.Mustache is in general very lenient of missing items. When an item does not exist, it will be simply rendered as empty string. Hence there are values to have a consistent behaviour for collection items. On the flipside, it is worth note that silently ignore all missing items could be a separate issue on its own.
The text was updated successfully, but these errors were encountered: