Menu
 

Composer errors

When composing your messages and using Liquid, you may sometimes see the little ‘Review Errors’ button go red and animate:

If you click it, you see the ‘Review Errors’ modal:

Inside that 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!

Variable ‘customer.eemail’ is missing

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 if only some customers have the attribute you’re trying to use (such as a trial expiration date). In that case, a fallback is a good solution:

{% if customer.trial_expires != blank %}
  Your trial ends on {{ customer.trial_expires | capitalize }}
{% endif %}



“can’t be blank”

subject can not be blank

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:

header ‘Content-Type’ cannot be set to a custom value

This means that you’ve tried to add a custom mail header that’s on our blacklisted list, and youll have to remove it.


can’t contain whitespace

Header name can’t contain whitespace

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

if tag was never closed

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:

capture tag does not expect else tag

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!


“Syntax Error in…”

This is a general error letting you know that the way you’ve written or fotratted 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:

Syntax Error in tag ‘if’ - Valid syntax: if [expression]

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:

Syntax Error in tag ‘assign’ - Valid syntax: assign [var] = [source]

{% 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’

Syntax Error in tag ‘capture’ - Valid syntax: capture [var]

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:

Syntax Error in ‘case’ - Valid syntax: case [condition]

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:

Syntax Error in tag ‘case’ - Valid else condition: {% 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:

Syntax Error in ‘cycle’ - Valid syntax: cycle [name :] var [, var2, var3 …]

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 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 %}

Syntax Error in ‘for loop’ - Valid syntax: for [item] in [collection]

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:

‘end’ is not a valid delimiter for if tags. use endif

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:

Variable {{ customer.trial_expires } was not properly terminated with regexp: /}}/

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:

Tag ‘{%’ was not properly terminated with regexp: /\%}/



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!