Composer errors
UpdatedWhen you compose messages and use Liquid, you may sometimes see the little Review Errors button turn red and animate.
If you click it, the Review Errors modal will let you know what’s wrong. Inside this modal, there can be a variety of outputs. This is a run-down of the most common ones, when you see them, and what you can do to fix them!
Variable is missing!
Error found in From
And it happens when the variable you’re trying to use in your email doesn’t exist for the customer whose sample data you’re using. This might be due to a simple misspelling (you’re trying to use {{ customer.eemail }}
instead of {{ customer.email }}
).
It could also be something a little more complicated. For example, you might see this error when only some People in your workspace have the attribute you’re trying to use and other People do not. In that case, using a fallback is a good solution.
can’t be blank
Error found in Subject
This one’s pretty self-explanatory. Certain fields — like your email subject, or a custom header’s name — can’t be left blank when you’re composing your message. Fill them in, and this one will go away.
cannot be set to a custom value
This might look like:
Error found in Headers
This means that you’ve tried to add a custom mail header that we have denylisted, and youll have to remove it.
can’t contain whitespace
Error found in Headers
This means that you’ve tried to add a header with a name that has a space in it. Remove the space and the error will disappear!
tag was never closed
Error found in Body
This happens when you open a liquid tag (something like if
, unless
, or case
), but forget to tell the composer where it ends.
So, this liquid would result in a ’never closed’ error:
{% if customer.trial_expires != blank %}
Your trial ends on {{ customer.trial_expires | capitalize }}
To fix it, close your tag!
{% if customer.trial_expires != blank %}
Your trial ends on {{ customer.trial_expires | capitalize }}
{% endif %}
does not expect ’else’ tag
Check out this liquid code:
{% capture about_me %}
I am 28 years old and my favourite drink is coffee!
{% else %}
I am 28 years old and my favourite drink is tea!
{% endcapture %}
That’ll give you this error:
Error found in Body
This just means that the {% else %}
tag inside the {% capture %}
tag I’m trying to use doesn’t belong there! To fix it, I need to either get rid of the {% else %}
, or change the tag it’s in!
Unidentified method
This error typically means that the liquid tag(s) you’re using don’t work with the specified variable. This often happens when you try to perform a math operation with an attribute or an assigned variable, because liquid treats attributes and assigned variables as strings!
You probably need to convert your variable to an integer/number to use the specific liquid tag using plus 0
, like the purchased_items
variable in the example below.
{% assign purchased_items = 0 | plus: 0 %}
{% for purchases in event.purchases %}
{% assign purchased_items = purchased_items | plus: 1 %}
{% endfor %}
Syntax Error in…
This is a general error letting you know that the way you’ve written or formatted a particular tag or variable isn’t quite right. You have to do a bit of diagnosing here, because the error is quite generic; it just informs you that your syntax isn’t correct. Here’s the specific cases, with some examples:
‘if’
This one looks something like:
Error found in Body
You’ll see it if you try to use Liquid like this, for example:
{% if %}
Your trial ends on {{ customer.trial_expires | capitalize }}
{% endif %}
In the above case, the condition is missing! “If,” what? To correct it, add your condition. In this case, it’s customer.trial_expires != blank
:
{% if customer.trial_expires != blank %}
Your trial ends on {{ customer.trial_expires | capitalize }}
{% endif %}
‘assign’
This syntax error means that you’ve done something wrong when trying to assign a variable. It looks like:
Error found in Body
{% assign = "apple" %}
The above creates a syntax error because I’m not specifying what “apple” should be assigned to. To fix it:
{% assign customer.favorite_food = "apple" %}
‘capture’
Error found in Body
You haven’t formatted your {% capture %}
correctly. Remember that it’s meant to grab a string and assign it to a variable.
For example, this would create a syntax error:
{% capture %}
I am {{customer.age}} and my favourite drink is {{customer.favourite_drink}}!
{% endcapture %}
I’m not telling the code what variable to assign the string to. In this case, I want the string to go into a variable called about_me
. Let’s fix it:
{% capture about_me %}
I am {{customer.age}} and my favourite drink is {{customer.favourite_drink}}!
{% endcapture %}
‘case’
‘case’ creates specific outputs based on specified variable values. A syntax error looks like:
Error found in Body
So this code is wrong (note the {% case %}
without a condition):
{% case %}
{% when 'USA' %}
Your order should be with you soon!
{% when 'Canada' %}
Your order should arrive in 3–4 days, eh?
{% else %}
Thank you for your order!
{% endcase %}
To get rid of the syntax error, I need to tell the liquid which customer attribute to look at for each ‘when’. So if I want it to look at the customer’s country…
{% case customer.country %}
{% when 'USA' %}
Your order should be with you soon!
{% when 'Canada' %}
Your order should arrive in 3–4 days, eh?
{% else %}
Thank you for your order!
{% endcase %}
Fixed!
Within case
, remember that you can also have errors with the when
or else
condition. They’ll look like this, and that just means you have to fix your when
or else
syntax specifically:
Error found in Body
{% else %}
(no parameters)‘cycle’
Cycle
loops through and outputs strings in the order they were passed, and it has to be used in a for
loop. It’s especially cool for HTML and CSS. The syntax error looks like this:
Error found in Body
Below is an example of correct syntax. Note that cycle
is in a for
loop, and that odd
and even
will alternate for each product in the array.
{% for item in customer.products %}
<div class="product-{% cycle 'odd', 'even' %}"> {{ item }} </div>
{% endfor %}
This will output the following HTML (depending on how many products there are):
<div class="product-odd">Product 1</div>
<div class="product-even">Product 2</div>
<div class="product-odd">Product 3</div>
If I tried to do this, though:
{% for item in customer.products %}
<div class="product-{% cycle | three %}"> {{ item }} </div>
{% endfor %}
It creates a syntax error because I haven’t told cycle
what to do each time it moves through the array. With this tag, you’re more likely to get strange outputs than syntax errors.
‘for’ loops
These have a couple of errors associated with them:
Syntax error
Say I’ve got some products stored in a {{ customer.products }}
variable:
["anvil", "rollerskates", "birdseed"]
and I want to loop through them in my message. For
loops are a way to do that, but the following code throws a syntax error:
{% for all {{customer.products}} %}
<div class="product-{% cycle 'odd', 'even' %}"> {{ product }} </div>
{% endfor %}
Error found in Body
I need to be a bit more specific, telling liquid what to loop through:
{% for product in {{customer.products}} %}
<div class="product-{% cycle 'odd', 'even' %}"> {{ product }} </div>
{% endfor %}
Unknown tag
Tags are specific, as you can probably tell from this doc! This error means that you’ve tried to use a tag that Customer.io doesn’t recognise.
Trying to use {% coyotes %}
in your email would result in:
Unknown tag ‘coyotes’
’end’ is not a valid delimiter
This error usually comes with a hint. For example:
Error found in Body
The above tells me that I haven’t closed my {% if %}
properly.
{% if customer.trial_expires != blank %}
Your trial ends on {{ customer.trial_expires }}
{% end %}
I’ve used {% end %}
instead of {% endif %}
was not properly terminated
Check out this liquid code:
{% if customer.trial_expires != blank %}
Your trial ends on {{ customer.trial_expires }
{% endif %}
The reason that would result in this error:
Error found in Body
is that {{ customer.trial_expires }
is missing its second curly bracket! Add it, the variable will be correctly closed, and the error will go away. The same goes for tags; if you haven’t closed a tag properly, you get a version of the same error:
Error found in Body
Questions?
This isn’t exhaustive, of course, but hopefully it’s a good run-down of the errors you might expect to see in the composer. If you have any questions, drop us an email!