# Composer errors

When 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![](#variable-is-missing)

 Error found in **From**

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 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](/journeys/using-liquid#fallbacks)** is a good solution.

## can’t be blank[](#cant-be-blank)

 Error found in **Subject**

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[](#cannot-be-set-to-a-custom-value)

This might look like:

 Error found in **Headers**

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

This means that you’ve tried to add a custom mail header that we have [denylisted](/journeys/custom-mail-headers), and youll have to remove it.

## can’t contain whitespace[](#cant-contain-whitespace)

 Error found in **Headers**

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[](#tag-was-never-closed)

 Error found in **Body**

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:

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

To fix it, close your tag!

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

## does not expect ’else’ tag[](#does-not-expect-else-tag)

Check out this liquid code:

```html
{% 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**

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!

## Unidentified method[](#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.

```fallback
{% assign purchased_items = 0 | plus: 0 %}
{% for purchases in event.purchases %}
  {% assign purchased_items = purchased_items | plus: 1 %}
{% endfor %}
```

## Syntax Error in…[](#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’[](#if)

This one looks something like:

 Error found in **Body**

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

You’ll see it if you try to use Liquid like this, for example:

```html
{% 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`:

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

#### ‘assign’[](#assign)

This syntax error means that you’ve done something wrong when trying to assign a variable. It looks like:

 Error found in **Body**

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’[](#capture)

 Error found in **Body**

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:

```html
{% 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:

```html
{% capture about_me %}
  I am {{customer.age}} and my favourite drink is {{customer.favourite_drink}}!
{% endcapture %}
```

#### ‘case’[](#case)

‘case’ creates specific outputs based on specified variable values. A syntax error looks like:

 Error found in **Body**

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

So this code is wrong (note the `{% case %}` without a condition):

```html
{% 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…

```html
{% 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**

Syntax Error in tag ‘case’ - Valid else condition: `{% else %}` (no parameters)

#### ‘cycle’[](#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**

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.

```html
{% 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):

```html
<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:

```html
{% 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[](#for-loops)

These have a couple of errors associated with them:

#### Syntax error[](#syntax-error)

Say I’ve got some products stored in a `{{ customer.products }}` variable:

```html
["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:

```html
{% for all {{customer.products}} %}
  <div class="product-{% cycle 'odd', 'even' %}"> {{ product }} </div>
{% endfor %}
```

 Error found in **Body**

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:

```html
{% for product in {{customer.products}} %}
  <div class="product-{% cycle 'odd', 'even' %}"> {{ product }} </div>
{% endfor %}
```

## Unknown tag[](#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[](#end-is-not-a-valid-delimiter)

This error usually comes with a hint. For example:

 Error found in **Body**

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

The above tells me that I haven’t closed my `{% if %}` properly.

```html
{% if customer.trial_expires != blank %}
  Your trial ends on {{ customer.trial_expires }}
{% end %}﻿
```

I’ve used `{% end %}` instead of `{% endif %}`

## was not properly terminated[](#was-not-properly-terminated)

Check out this liquid code:

```html
{% 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**

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:

 Error found in **Body**

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

## Questions?[](#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](mailto:win@customer.io)!