Jinja errors

This article explains common errors you may encounter when using Jinja and how to resolve them.

NoneType object isn't iterable

This error occurs when Jinja tries to iterate over an empty, nonexistent, or non-iterable object.

Solution: Check whether the object exists and is iterable for the customer you are previewing the code for.

Not supported between instances of NoneType and int

This error occurs when you try to compare a null element with a value. For example, when a catalog value like item.price is empty and your email contains the comparison {% if item.price > 0 %}.

Solution: Check whether the element is null before comparing it, or set elements to be compared only if their values are greater than zero.

{% if item.price %}
  {% if item.price > 0 %}
    {# Your code here #}
  {% endif %}
{% endif %}

Not supported between instances of str and int

This error occurs when you compare a string element to a number. For example, {% if "3" > 0 %}.

Solution: Use a Jinja filter to convert the data type to a number (int or float).

{% if "3" | int > 0 %}
  {# Your code here #}
{% endif %}

Template rendering timeout

This error occurs when your Jinja code is too complex. Common causes include:

  • Too many catalog or recommendation calls.
  • Long computing time for Jinja operations.
  • Too many nested iterations (for and if loops).

Solution: Simplify and optimize your Jinja code. Consider:

  • Reducing the number of catalog calls by batching requests.
  • Breaking complex operations into smaller steps.
  • Minimizing nested loops.

Error fixes

Review the Jinja FAQ for details on error fixes.


© Bloomreach, Inc. All rights reserved.