theme-tools icon indicating copy to clipboard operation
theme-tools copied to clipboard

`ValidSchema` reports incorrect validation error when block in preset is disabled

Open david-w-shopify opened this issue 10 months ago • 2 comments

Describe the bug I'm copying some json from a template over to some schema presets and getting a theme check ValidSchema error with the wrong message.

Source

// sections/test.liquid

{% schema %}
{
  "name": "Test",
  "blocks": [{ "type": "@theme" }],
  "presets": [
    {
      "name": "Preset",
      "blocks": {
        "button": {
          "type": "button",
          "disabled": true
        }
      }
    }
  ]
}
{% endschema %}

Expected behaviour "disabled": true is reported as invalid. Theme Check flags a more useful error.

For what it's worth while I think this should be flagged as invalid, it is actually accepted by the platform, despite being useless.

Actual behaviour The entire "blocks" value under the "Preset" preset throws an ValidSchema error with the message in the screenshot

Image

Debugging information

  • OS: macOS
  • OS Version: Sequoia 15.2
  • Theme Check Version: Unknown, according to CLI. I have @shopify/[email protected] installed though so whichever version is used by that

david-w-shopify avatar Jan 31 '25 13:01 david-w-shopify

Hey @david-w-shopify! I'm pretty sure the schema validation is behaving as intended here. The "blocks" attribute should be passed an array of objects, not a single object: https://shopify.dev/docs/storefronts/themes/architecture/blocks/theme-blocks/schema#presets

graygilmore avatar Jan 31 '25 18:01 graygilmore

After chatting with David a bit I think there is a bug here. It's treating any non-valid attribute as a schema error (good!) but bubbling it up to a parent issue. We'll take a look at this.

graygilmore avatar Jan 31 '25 22:01 graygilmore