Repository navigation
Fix theme check JSON output for offenses without a position - #9041
Merged
isaacroldan merged 1 commit intoOct 30, 2026
Merged
Conversation
Theme Check reports line and character -1 for an offense that it cannot place, for example a missing required object in an empty layout/theme.liquid. The JSON projection added 1 to these values, which produced 0, and the strict one-based schema rejected the result. So `shopify theme check --json` failed with a ZodError instead of printing the issues. Clamp each projected position to at least 1, so these offenses point at the start of the file and the output keeps its one-based contract. Co-authored-by: isaac.roldan <[email protected]>
karreiro
approved these changes
Oct 30, 2026
karreiro
left a comment
Contributor
There was a problem hiding this comment.
Thank you, @isaacroldan!
isaacroldan
deleted the
torrent/devxg-10-p1-error-code-too-small-minimum-0-type-n
branch
October 30, 2026 16:26
1 of 4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
WHY are these changes introduced?
shopify theme check --jsonfails when Theme Check reports an offense that it cannot place in the file. Theme Check gives line and character-1for such an offense, for example when an emptylayout/theme.liquidmisses{{ content_for_header }}. The JSON projection adds 1 to each position, so the result is0. The output schema requires one-based positions greater than 0, so the command prints aZodError("Number must be greater than 0", pathissues, <n>, startRow) instead of the issues.WHAT is this pull request doing?
It clamps each projected position to at least 1. An offense without a known position now points at the start of the file. The schema and its one-based contract do not change. A regression test covers an offense with
-1positions.Output before, for a theme with an empty
layout/theme.liquid:Output after:
How to manually test your changes?
mkdir -p /tmp/empty-theme/layout && touch /tmp/empty-theme/layout/theme.liquid.pnpm shopify theme check --path /tmp/empty-theme --json.RequiredLayoutThemeObjectissues at row 1, column 1, and noZodError.Checklist
patchfor bug fixes ·minorfor new features ·majorfor breaking changes) and added a changeset withpnpm changeset add