Shopify / Shopify/liquid

[Bug] metafield list types, inaccessible values

Open
#1,585 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
11.9k
Forks
1.5k
Avg merge
17h 55m
Merged PRs (30d)
3

Description

Recently Shopify released the ability to create Metafield Definitions for a List of Values. The content of these metafields is an iterable and accessed via the value property.

This works for most of the new content types. However some of the content types return either null or throw an internal error.

I've put together an exhaustive table of all the metafield list types and whether they work property or are broken. The code below the table can be used to recreate the issue. (with appropriately created metafield definitions)

list.weight                   (bug: meta.value throws internal error)
list.volume                   (bug: meta.value throws internal error)
list.dimension                (bug: meta.value throws internal error)
list.page_reference           (bug: meta.value is null)
list.rating                   (bug: meta.value throws internal error)
list.date                     (works)
list.date_time                (works)
list.number_integer           (works)
list.number_decimal           (works)
list.product_reference        (works)
list.single_line_text_field   (works)
list.color                    (works)
list.file_reference           (works)
list.url                      (works)

sandbox_playground.liquid

<!--
# WORKING EXAMPLES
   - where metafield.value returns a list of values

list.single_line_text_field:
  json: {{ product.metafields.specs.textsingle_list.value | json }}
  el: {{ product.metafields.specs.textsingle_list.value[0] | json }}
  str: {{ product.metafields.specs.textsingle_list | prepend: "" }}


# FAILING EXAMPLES
   - where metafield.value returns either null or throws an error

list.page_reference:
  json: {{ product.metafields.specs.pageref_list.value | json }}
  el: {{ product.metafields.specs.pageref_list.value[0] | json }}
  str: {{ product.metafields.specs.pageref_list | prepend: "" }}

list.rating_list:
  json: {{ product.metafields.specs.rating_list.value | json }}
  el: {{ product.metafields.specs.rating_list.value[0] | json }}
  str: {{ product.metafields.specs.rating_list | prepend: "" }}
-->

output

<!--
# WORKING EXAMPLES
   - where metafield.value returns a list of values

list.single_line_text_field:
  json: ["cat","dog"]
  el: "cat"
  str: ["cat","dog"]


# FAILING EXAMPLES
   - where metafield.value returns either null or throws an error

list.page_reference:
  json: ""
  el: null
  str: ["gid://shopify/OnlineStorePage/88645664920","gid://shopify/OnlineStorePage/91070595224"]

list.rating_list:
  json: Liquid error: internal
  el: Liquid error: internal
  str: [{"scale_min":"0.0","scale_max":"5.0","value":"1.0"},{"scale_min":"0.0","scale_max":"5.0","value":"3.0"}]

-->

Converting the entire metafield to a String via prepend "" was only done to show that the metafield is in fact not empty. Unfortunately this is not helpful when actually trying to iterate over the metafield contents.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the sandbox_playground.liquid reproduction and the documented metafield.value examples. Compare the failing list types—weight, volume, dimension, page_reference, and rating—with the working types; done means their values are accessible and iterable without null results or internal errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.