Why did the Liquid array .size function stop working in my customized theme?

Michael, thanks for your response.

I believe metafields.invalid_namespace returns an empty array, not null. So .size should return 0.

If metafields.invalid_namespace returned null I would simply say

{% if product.metafields.my_metafield_namespace %}

and get rid of the .size call altogether.

The real issue is that I had production code working for months and it suddenly broke without any changes to product metadata or theme code.