Exceeded maximum number of unique handles

Short description of issue

Limitation for dynamic source referenced on page

Link to Shopify Store

shopdev-alliance.myshopify.com

Reproduction steps

The same metaobject is referenced as a dynamic source on the page with different blocks

After approximately 20, the same metaobject can no longer be referenced on the page anymore.

Our metaobjects here are set up as “Member Benefits” and then they each have different properties we’re using here, but essentially after we get to about 20 they no longer output and provide the error Liquid error: Exceeded maximum number of unique handles for member_benefits.

Additional info

I CAN switch to a different metaobject as a source. The issue seems to be that we have multiple sections that are rendering these different benefits as blocks on the page from the same source.

As soon as I change the source, no issue. I’m not at the section or block limit for any of these within the editor.

I CAN render more of these out via code directly, but if I try to reference as a dynamic source is the issue.

You can see the error live at the bottom of the page at https://shopdevalliance.com/pages/benefits under Events category.

What type of topic is this

Bug report

Upload screenshot(s) of issue

1 Like

I went ahead and am just looping over these with code instead of using as a dynamic source - for the moment, I’ll just consider this is a limitation

Ran into this just a few days ago as well.
Here is my write-up about it: Exceeded maximum number of unique handles for metaobject handle

tl;dr

However, it is interesting, that you could query more metaobject entries, when you switched to a different metaobject definition :thinking:

1 Like

Yeah, I think this is the part that confuses me - it seems specific to instances where the same metaobject is referenced multiple times as a dynamic source.

This is different than the looping limitations requiring pagination for metaobjects. It is some sort of limitation specific to the dynamic source being referenced.

The “easy” fix for us as devs is to wrap it in a paginate and then the same code becomes valid (I just set up text inputs to act as qualifiers for the type of metaobject and the filter for that section. This makes it flexible enough for future metaobjects, but again, this limitation with metaobjects seems - odd.

1 Like

We were using metaobjects and had a large number of them that needed to render for swatches and when looping through meetaobjects we saw an insane decrease in site speed. I now reference them by handle which is way faster but the limit of 20 kills for the few products we have with more than 20 colors.

*Yes I know about the Shopify swatches on product category metafields and all that we have other limitations there that make that not feasible right now.

I really wish the limit would at least go to something like 50.

1 Like

Hey folks - update on this, it’s intentional and there’s currently no plans to expand this limit:

you’re limited to 20 unique handles per page and can’t use pagination

from: Liquid objects: metaobject_definition

Here is the full quote of the note on the docs page.

When looping through metaobjects by accessing them using individual handles (e.g., metaobjects.TYPE[handle]), you’re limited to 20 unique handles per page and can’t use pagination. To iterate over more metaobjects, instead use the values property, which supports pagination up to 250 entries per page.

What confuses me is

When looping through metaobjects by accessing them using individual handles

I think the “by” in that sentence should be a “and” or something of the sorts.
Accessing metaobjects using individual handles, is not a method of looping over them, so the “by” doesn’t make sense.

If it is meant to say, that accessing metaobjects using individual handles in a loop, then it needs a bigger change. Something like “When accessing metaobjects using individual handles in a loop”.

If the limit only concerns accessing metaobjects using individual handles in a loop, is it possible to access more of them on each given page/template? Of course, as long as the unique handle lookup is not in a loop or doesn’t exceed the limit per loop?

My observation was, that the limit of 20 doesn’t just apply to metaobjects accessed using individual handles, but metafield lookups (in the same loop) counted against that limit too.
Is that true and expected?