Bug: Metafields with a key of 'size'

There’s a rather hillarious (but painful) bug with metafields with a key of size.

If you try and access the metafield value with the following code…

{{ product.metafields.custom.size }}

You won’t actually be getting the value, but instead getting the total number of metafields against the custom namespace (or whatever namespace you’ve chosen). This is because of the .size or | size Liquid filter

To get around this you have to use:

{{ product.metafields.custom["size"] }}

So to save many developers in the future headaches… I’m proposing that size and any other applicable liquid filters are in fact reserved metafield keys going forward.

4 Likes

Hi Ceri,

Thanks for flagging this - connecting with our internal teams to investigate this issue.