CASE: limit range below 200 accounts (error "Range 'some range' would have more than 200 items")

In rare cases, you might accidentally bump into an error that mentions the following:

Liquid error: Range ‘140100__140350’ would have more than 200 items, which is not allowed in code: assign some_accounts = period.accounts | range:some_range

What does this error mean?

This error means that the variable that defines the range (so some_range) has more than 200 possible accounts to be checked.

We don’t allow this, due to performance reasons.

So giving a range like 1__7 means in the background, 7 items are checked by the background query (meaning, less than 200), which will be fine.
However, a range like 700100__700301 will mean the background query will check 201 possible ranges (more than 200), and will result in an error.

How can this be solved?

In the rare cases you do need to call upon all these accounts, you’ll need to split up the range in several parts, like this:

{% comment %}define several ranges where each part does not have more than 200 accounts{% endcomment %}
{% assign some_range = "14010_14034,140350" %} 

So by splitting the range into several parts, where each part does not have more than 200 items, can you workaround this error.

We hope this happens rarely though, but figured it probably is worth mentioning it.

1 Like