Skip to content

Add SchemaPresetsAndDefault check - #1302

Open
web-orbit12 wants to merge 1 commit into
Shopify:mainfrom
web-orbit12:fix/750-schema-presets-and-default
Open

web-orbit12 wants to merge 1 commit into
Shopify:mainfrom
web-orbit12:fix/750-schema-presets-and-default

Conversation

@web-orbit12

@web-orbit12 web-orbit12 commented Sep 22, 2026 •

Copy link
Copy Markdown

What are you adding in this PR?

Fixes #750

A section schema that defines both presets and default passes Theme Check today, but shopify theme dev rejects it with:

Invalid schema: cannot define both 'default' and 'presets'

This adds a SchemaPresetsAndDefault check that reports the same error in the editor and in shopify theme check, highlighting the default value.

  • Runs on section files only: theme block schemas have no default property.
  • Only reports on otherwise valid schemas, like the other SchemaPresets* checks.
  • The message matches the platform error word for word.

What's next? Any followup issues?

The check needs a page on shopify.dev (checks/schema-presets-and-default), which a Shopify team member would have to add.

I treated key presence as the trigger, so an empty presets: [] with default is also flagged. Happy to switch to non-empty presets only if the platform accepts that combination.

Tophatting

  • Put the schema below in sections/test.liquid: the error appears on default. Remove either key and it goes away.
{% schema %}
{
  "name": "Test",
  "presets": [{ "name": "Test" }],
  "default": { "settings": {} }
}
{% endschema %}
  • Tested in the playground (pnpm playground) with the section above, built from main and from this branch:

Before (main @ 8bc5e03): no error

Before: main, no error

After (this branch @ d4dcdf9): default is flagged

After: this branch, error on default
  • pnpm vitest run packages/theme-check-common/src/checks/schema-presets-and-default (5 tests), plus the full theme-check-common and theme-check-node suites pass.

  • I added screenshots of the changes (before and after the changes if applicable)

Before you deploy

  • This PR includes a new checks or changes the configuration of a check
    • I included a minor bump changeset
    • I ran pnpm build and committed the updated configuration files
      • If applicable, I've updated the theme-app-extension.yml config (not applicable: in app mode, sections have no schema to check, so the check is a no-op)

Reports section schemas that define both presets and default, which
`shopify theme dev` rejects with "Invalid schema: cannot define both
'default' and 'presets'".

Fixes Shopify#750
@web-orbit12
web-orbit12 requested a review from a team as a code owner September 22, 2026 19:29
@web-orbit12

Copy link
Copy Markdown
Author

I have signed the CLA!

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Theme check should warn you when you have presets and default

1 participant