Jinja errors

In this article, we explain some of the errors that you may encounter when using Jinja in Bloomreach Engagement.

Error 1: NoneType object is not iterable

The error occurs when Jinja tries to iterate an empty, nonexistent, or uniterable object. To solve this, check whether the object in the condition exists and is iterable for the customer you are previewing the code for.

Error 2: Not supported between instances of NoneType and int

The error occurs in Jinja when you are trying to compare the null element with some value. For example, when catalogue value item.price is empty and email contains comparison {% if item.price > 0 %}. To solve this, check whether the element isn't null or set the elements to be compared only if the items' values are higher than zero. For example, {% if item.price %}{% if item.price > 0 %}.

Error 3: Not supported between instances of 'str' and 'int

The error occurs when an element with datatype "string" is compared to a number. For example, {% if "3" > 0 %}. To solve this, use a Jinja filter to convert the data type to a number (int or float). The result could look like this: {% if "3"|int > 0 %}.

Error 4: Template rendering timeout

The error occurs when Jinja is too complex. For example, there are too many calls in catalogs or recommendations, too long computing time for Jinja, or too many layers of iterations ("for" and "if" cycles). To solve this, simplify and optimize the Jinja you are using.

Error fixes

Review the Jinja FAQ for details on error fixes.