Welp! I got a message saying "Encountered an error: 'bool' object is not iterable"

Question

I got an error message saying:

Encountered an error:
'bool' object is not iterable

What should I do?

Answer
This is a Jinja error that happens when you try to iterate on an object that is considered a bool. For me, this most frequently happens when I try to use a Jinja object that doesn’t exist in my context, so it compiles to None (which is also type=bool by default). This is because dbt does not use the StrictUndefined setting in Jinja.

I’d recommend checking out the target/dbt.log file to find what caused this error as it can give you insight into which model has the bad Jinja in it. Once you know which model it is, the things to look out for are:

  • Using a package macro before running dbt deps
  • Operating on an object that you’ve misspelled