cli icon indicating copy to clipboard operation
cli copied to clipboard

[Bug]: Theme input settings do not allow types "metaobject" or "metaobject_list"

Open wallfly opened this issue 1 year ago • 3 comments

Please confirm that you have:

  • [x] Searched existing issues to see if your issue is a duplicate. (If you’ve found a duplicate issue, feel free to add additional information in a comment on it.)
  • [x] Reproduced the issue in the latest CLI version.

In which of these areas are you experiencing a problem?

Theme

Expected behavior

I should be able to add the input setting type of "metaobject" or "metaobject_list" and the Theme / Schema validator in theme dev would validate it and allow the theme to properly render the input settings in the Theme editor.

Actual behavior

When I add the input setting in my section liquid file using type "metaobject" or "metaobject_list", theme dev cannot validate my input setting type and prints:

Invalid schema: setting with id="faq_metaobject_list" type is invalid

Verbose output

DEBUG Refreshing preview _shopify_essential cookie
DEBUG Proxying HEAD https://mystore.myshopify.com/?preview_theme_id=139015553201&_fd=0&pb=0
DEBUG `-> 302 request_id: 6d62c030-fc60-412a-bca2-c9933404e43e-1725505530
DEBUG Proxying GET https://mystore.myshopify.com/pages/lp/chiropractic-offices?_ab=0&_fd=0&_sc=1&pb=0&preview_theme_id=139015553201&_fd=0&pb=0
DEBUG `-> 302 request_id: 9298587f-762c-4b64-abb0-bd910798222f-1725505531
DEBUG Proxying GET https://mystore.myshopify.com/pages/lp/chiropractic-offices?_ab=0&_fd=0&_sc=1&pb=0&_fd=0&pb=0
DEBUG `-> 200 request_id: 92c1bd99-23e4-46a6-8e50-0834118e50c6-1725505531
DEBUG Renew _shopify_essential cookie by the response
DEBUG Proxying GET https://mystore.myshopify.com/checkouts/internal/preloads.js?locale=en-US&_fd=0&pb=0
DEBUG [HotReload] Connected to SSE stream
DEBUG `-> 200 request_id:
DEBUG Proxying GET https://mystore.myshopify.com/cart.js?r=2.50096004167&_fd=0&pb=0
DEBUG `-> 200 request_id: fce4a8c1-6357-4c29-b79f-67076d84dc01-1725505534
DEBUG Proxying GET https://mystore.myshopify.com/pages/lp/chiropractic-offices?_ab=0&_fd=0&_sc=1&pb=0&_fd=0&pb=0
DEBUG `-> 200 request_id: c12aee9a-5636-4252-bee1-7b52148a69e7-1725505680
DEBUG Renew _shopify_essential cookie by the response
DEBUG Proxying GET https://mystore.myshopify.com/checkouts/internal/preloads.js?locale=en-US&_fd=0&pb=0
DEBUG [HotReload] Connected to SSE stream
DEBUG `-> 200 request_id:
DEBUG Proxying GET https://mystore.myshopify.com/cart.js?r=2.50093676816&_fd=0&pb=0
DEBUG `-> 200 request_id: 6835b03c-fc14-4fa2-af68-0f1ebcbf178f-1725505681
DEBUG [HotReload] Modified sections/collapsible-faqs.liquid
DEBUG update sections/collapsible-faqs.liquid
DEBUG Proxying POST https://mystore.myshopify.com/pages/lp/chiropractic-offices?_ab=0&_fd=0&_sc=1&pb=0&_fd=0&pb=0
DEBUG PUT https://mystore.myshopify.com/admin/api/unstable/themes/139015553201/assets.json with request_id: d5d0a91a-5cde-4a5d-8e8d-6bd721e08b52-1725505701
  • 20:08:22 ERROR  » update sections/collapsible-faqs.liquid:
  Invalid schema: setting with id="faq_metaobject_list" type is invalid
DEBUG `-> 200 request_id: 5f7fe91d-5f33-4436-adad-3d164de82b7f-1725505701
DEBUG Renew _shopify_essential cookie by the response
DEBUG Proxying GET https://mystore.myshopify.com/checkouts/internal/preloads.js?locale=en-US&_fd=0&pb=0
DEBUG [HotReload] Connected to SSE stream
DEBUG Proxying POST https://mystore.myshopify.com/cart.js?r=2.50094045164&_fd=0&pb=0
DEBUG `-> 200 request_id:
DEBUG `-> 200 request_id: abcf042d-6edc-46cb-a073-f5e3c1e6527c-1725505703

Reproduction steps

I have been getting into the metaobject definitions and creating themes for these, so I can template pages and easily populate them in a set of inputs rather than coding up new files each time. Great! I was excited as it fit a need.

Created my metaobjects and then a template for them. Each template and liquid section would then bind it's input values to the values in the metaobject entry.

I have created a sales_landing_page metaobject with 2 dozen fields in it. I also have a faqs metaobject with 2 fields in it (question and answer). Each landing page does not need the same FAQs, but the most relevant ones.

This means I needed a 1:many cardinal relationship in my 2 "database tables", wanting many FAQs on one Landing Page entry. So I created a new field on sales_landing_page as a metaobject reference, referencing the faqs metaobject.

Where I get blocked is creating a theme input setting allowing me to bind an input setting to the faq metaobject reference field on my sales_landing_page.

Except I was not sure what input setting type to use. The Shopify docs do not show any reference to metaobject or metaobject_list input setting types. HOWEVER, VScode intellisense shows me these two types, so went forward with it.

At first I just put metaobject_list but then the schema validator told me that metaobject_type was required. But I could not find ANY documentation on this either.

Intellisense provides me this link to refer to the metaobject_list input setting type, but this page makes no reference. https://shopify.dev/docs/themes/architecture/settings/input-settings#metaobject_list

  1. Run shopify theme dev on an existing working theme and load your local env pages that you will work on
  2. In a code editor, open an existing or new liquid section file, add a new input setting with "type": "metaobject" or "type": "metaobject_list" ... Here is mine:
  "settings": [
   ...,
    {
      "type": "metaobject_list",
      "metaobject_type": "faqs",
      "id": "faq_metaobject_list",
      "label": "FAQs metaobject reference"
    },
    ...
   ]
  1. Save the file to allow for hot reloading
  2. See the output in the theme dev terminal where it will show: Invalid schema: setting with id="faq_metaobject_list" type is invalid

Operating System

Mac OS Sonoma 14.6.1

Shopify CLI version (check your project's package.json if you're not sure)

Shopify CLI; v=3.66.1

Shell

zsh

Node version (run node -v if you're not sure)

No response

What language and version are you using in your application?

No response

wallfly avatar Sep 05 '24 03:09 wallfly

Maybe this can help? https://shopify.dev/docs/storefronts/themes/architecture/settings/dynamic-sources#referencing-metaobject-fields

etienne-ditchlabs avatar Sep 10 '24 15:09 etienne-ditchlabs

Maybe this can help? https://shopify.dev/docs/storefronts/themes/architecture/settings/dynamic-sources#referencing-metaobject-fields

Thanks @etienne-ditchlabs -- I have tried this as well, but could not get it to do what I needed, given the limitations of Liquid.

Here is a similar scenario to the FAQs, but with different data.

  • I have an citations metaobject, which contains a topics_list that tells me what the citation is about (ie, 'sleep','cardiovascular','anxiety')
  • and a sales_landing_page metaobject that has a field for relevant_citation_topics - here I want to choose which citations to show, so I will have another list of topics (ie, 'sleep','stress')
  • Then I want to be able to do a contains check to match and filter for citations that match my sales_landing_page.relevant_citation_topics
  • But this has proven quite difficult, perhaps not possible. The contains check does not ever yield TRUE even when the strings match exactly
  • This ALSO has the distinct disadvantage of having to pull ALL citations and then filter after, instead of being able to query using a where filter

wallfly avatar Sep 10 '24 18:09 wallfly

This isn't a bug but more of a feature suggestion to Shopify - they aren't supported as input settings within the theme editor which is why you will get the error you will.

If you view this, you can see in the sidebar what is supported: https://shopify.dev/docs/storefronts/themes/architecture/settings/input-settings

rcasimmons avatar Oct 02 '24 10:10 rcasimmons

I understand now after some time and found some other ways around it.

But here is the "bug": the Shopify Liquid VScode extension pointed me in the direction of this new input type of metaobject and metaobject_list but it doesn't exist, as you've confirmed here.

Perhaps this planned feature or addition has leaked into the Liquid docs on the extension?

wallfly avatar Oct 10 '24 17:10 wallfly

I understand now after some time and found some other ways around it.

But here is the "bug": the Shopify Liquid VScode extension pointed me in the direction of this new input type of metaobject and metaobject_list but it doesn't exist, as you've confirmed here.

Perhaps this planned feature or addition has leaked into the Liquid docs on the extension?

I think you're right - looks like Shopify may be gearing up to add support for this in the customizer and it's sadly leaked with the a new release of the VSCode extension.

rcasimmons avatar Oct 16 '24 12:10 rcasimmons

Hey @wallfly @rcasimmons , to confirm this is not a bug on the CLI but rather the Liquid VScode extension suggested invalid types, which is what caused this? If so I'll bring this feedback to the team and close this issue?

lucyxiang avatar Oct 17 '24 20:10 lucyxiang

@lucyxiang Yes it all started with the Liquid VScode extension that led me to believe I could use these new input types. If that suggestion had not been there, I wouldn't have gone down this approach.

I do think that it's a worthwhile addition to the input type options for settings. I am strongly in favor of adding those. Otherwise it's hard to build a scalable relational data model with metaobjects.

wallfly avatar Oct 21 '24 17:10 wallfly

Can confirm, same thing happened to me (suggestion by VS Code extension leads to trial & error and then google rabbithole which after some time leads to mild disappointment here), and same feature request from me

philiprichter avatar Oct 28 '24 01:10 philiprichter

Facing the same issue, I've tried to use this mutation to create metaobject definition

mutation {
  metaobjectDefinitionCreate(definition: {
    type: "$app:product_highlight_2",
    access: {
      admin: MERCHANT_READ_WRITE,
      storefront: PUBLIC_READ
    },
    capabilities: {
      publishable: {
        enabled: true
      }
    },
    fieldDefinitions: [
      { key: "title", name: "Highlight Title", type: "single_line_text_field" },
      { key: "description", name: "Description", type: "multi_line_text_field" }
    ]
  }) {
    metaobjectDefinition {
      id
      type
      fieldDefinitions {
        key
        name
        type {
          name
        }
      }
    }
  }
}

This gives me id and type, but still getting same issue Invalid tag 'schema': settings

Would be grate to know if it works for anyone at all ?

paxti avatar Nov 10 '24 06:11 paxti

@wallfly @rcasimmons the original error is because metaobject and metaobject_list code recommendations were shipped before the metaobject and metaobject_list feature was shipped, but they are now both shipped, you can see the docs here https://shopify.dev/docs/storefronts/themes/architecture/settings/input-settings#metaobject

I'll bring feedback to the team to avoid this due to the confusion it may cause

lucyxiang avatar Nov 18 '24 15:11 lucyxiang

@paxti it seems this mutation issue is unrelated to the CLI, if it's still persisting I think you'll have better luck in the dev community forum https://community.shopify.dev/

lucyxiang avatar Nov 18 '24 15:11 lucyxiang

I've been trying to use the metaobject type as per documentation in this link https://shopify.dev/docs/storefronts/themes/architecture/settings/input-settings#metaobject in a theme app extension but I keep getting blocked with the following validation error whenever I set the type to metaobject or metabject_list.


 bundle: [blocks/test.liquid] Invalid tag 'schema': settings:   │
│      with id="test_data" type is invalid

Is this actually shipped? Can I use it? Is there an estimated timeframe for official release?

JonidBendo avatar Nov 21 '24 09:11 JonidBendo

hi, any updates?

IIIIIIIIlIIII avatar Nov 28 '24 16:11 IIIIIIIIlIIII

Hi! It seems there's a bug specifically in theme app blocks. We're looking into it. Really sorry for the inconvenience.

mbarak avatar Nov 29 '24 01:11 mbarak

Having the same issue as @JonidBendo, specifically with a theme app extension. Any updates?

dansundy avatar Dec 05 '24 02:12 dansundy

Is there an ETA or workaround on this? Tying to use metaobjects as input on block settings, throws this error and blocks deploy.

gabrielboliveira avatar Dec 10 '24 16:12 gabrielboliveira

I’m encountering the same issue. It would be helpful to know if there’s an estimated timeline for a fix/workaround.

tanmayjay avatar Dec 10 '24 17:12 tanmayjay

I'm also experiencing this issue.

mattsparks avatar Dec 10 '24 17:12 mattsparks

+1

bvdr avatar Dec 10 '24 20:12 bvdr

This issue seems inactive. If it's still relevant, please add a comment saying so. Otherwise, take no action. → If there's no activity within a week, then a bot will automatically close this. Thanks for helping to improve Shopify's dev tooling and experience.

P.S. You can learn more about why we stale issues here.

github-actions[bot] avatar Jan 22 '25 03:01 github-actions[bot]