Skip to content

Recognize schema settings as block variables in UndefinedObject - #1319

Merged
charlespwd merged 1 commit into
mainfrom
fix-undefined-object-block-schema-variables
Oct 1, 2026
Merged

charlespwd merged 1 commit into
mainfrom
fix-undefined-object-block-schema-variables

Conversation

@charlespwd

Copy link
Copy Markdown
Contributor

In this PR

UndefinedObject now treats a theme block's schema settings as defined variables. A block can use {{ heading }} for its heading setting without repeating it as a LiquidDoc @param.

Problem

Inside a theme block, a schema setting is available as both {{ heading }} and {{ block.settings.heading }}. Block-call validation, completion, and hover already follow that rule. UndefinedObject only knew about LiquidDoc parameters and content, so it flagged every bare schema setting.

So if blocks/card.liquid is:

<h2>{{ heading }}</h2>

{% schema %}
{ "name": "Card", "settings": [{ "type": "text", "id": "heading", "label": "Heading" }] }
{% endschema %}

main reports:

Unknown object 'heading' used.

Solution

In a block file, UndefinedObject asks context.getBlockParameters for the current block and adds every name it returns to the file's defined variables. Block-call validation and block-tag completion and hover use the same resolver, so the check gets the same variable set:

  • id-bearing input settings from the block's valid schema;
  • LiquidDoc parameters; and
  • built-in content.

Names declared by both schema and LiquidDoc count as one variable. Any other unknown root is still reported.

Boundaries:

  • header and paragraph entries don't define variables, and neither do setting type values such as color_background.
  • When the schema doesn't parse, the resolver returns nothing. LiquidDoc parameters and content stay defined, as before.
  • Sections, snippets, templates, layouts, and app blocks get no bare schema variables.

Reproduction and checks

does not report a schema setting used as a bare variable failed on main with Unknown object 'heading' used. and passes with this change. Without the fix, 5 of the 9 new tests fail. The other 4 cover behavior that stays the same.

  • CI=1 pnpm exec vitest run packages/theme-check-common/src/checks/undefined-object/index.spec.ts: 46 passed
  • CI=1 pnpm exec vitest run packages/theme-check-common: 5,365 passed
  • pnpm --filter @shopify/theme-check-common type-check
  • pnpm format:check
  • git diff --check

Before you deploy

  • I included a patch bump changeset

@charlespwd
charlespwd marked this pull request as ready for review October 1, 2026 14:19
@charlespwd
charlespwd requested a review from a team as a code owner October 1, 2026 14:19

@karreiro karreiro left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @charlespwd 🚀

@charlespwd
charlespwd merged commit 4574b6a into main Oct 1, 2026
8 checks passed
@charlespwd
charlespwd deleted the fix-undefined-object-block-schema-variables branch October 1, 2026 14:21
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.

3 participants