Shopify / Shopify/liquid

Metafields type vs value_type breaks the liquid json function

Open
#1,657 0 comments 0 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

I followed the directions to migrate to "type" instead of "value_type" for Shopify metafields.
https://shopify.dev/apps/metafields/migration

After switching, I can no longer transform metafields to json in liquid.

This code has always worked:

{{ product.metafields.merch | json }}

Actual output:
Screen Shot 2022-11-15 at 8 20 59 PM

Expected output:
Screen Shot 2022-11-15 at 8 21 48 PM

Old API code (works):

{
      key: 'preview_image',
      value: JSON.stringify({
        src: previewImage.url,
        contentType: previewImage.contentType,
      }),
      value_type: "json_string",
      namespace: "merch",
}

New API code (breaks liquid):

{
      key: 'preview_image',
      value: JSON.stringify({
        src: previewImage.url,
        contentType: previewImage.contentType,
      }),
      type: "json",
      namespace: "merch",
}

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 by reproducing the Liquid json filter with the issue's old value_type and new type metafield examples. Trace the json filter behavior for Shopify metafields, then add coverage for the new type form and confirm the output matches the expected JSON representation.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, ruby
Domain
web-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.