Validate extensions.targeting assets value in include-assets-step#7504
Open
JoshuaWhite1 wants to merge 1 commit intomainfrom
Open
Validate extensions.targeting assets value in include-assets-step#7504JoshuaWhite1 wants to merge 1 commit intomainfrom
JoshuaWhite1 wants to merge 1 commit intomainfrom
Conversation
64c1e3a to
6ef723c
Compare
6ef723c to
6feec59
Compare
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?
closes https://github.com/shop/issues-admin-extensibility/issues/2521
When a developer sets an invalid assets value in [[extensions.targeting]] (empty string, ., ./, ../foo, etc.), the CLI currently builds the extension, compresses the bundle, and uploads it to GCS before the server rejects the deployment. When we pivoted to the extensions approach for hosted apps, we lost the contract validations from the admin module. That included: empty static_root (now called assets), length limit of 80 char, root path
./,., and parent directories like../.The app will still currently fail, but with an incorrect error message, and further downstream. i.e. defining assets =
./, it is attempting to upload the entire project directory which contains node modules and fails the file limit validation:WHAT is this pull request doing?
Adds a build-time guard in the include_assets step that validates assets values before bundling. Specifically:
The guard fires before copyConfigKeyEntry runs, so a misconfigured value short-circuits the build instead of producing a bundle that the server later rejects.
How to test your changes?
shopify app init --template https://github.com/Shopify/shopify-app-template-extension-onlyassetsvalue underextensions.targetinginextensions/app-home/shopify.extension.toml../../shopify app dev+shopify app deployin your local CLI, pointing to your app template:SHOPIFY_CLI_NEVER_USE_PARTNERS_API=1 SHOPIFY_SERVICE_ENV=local pnpm run shopify app dev --path="<PATH_TO_APP>"assetsvalue in your toml back to valid casesassets./assetsConsiderations
Considered applying this in two alternative layers:
cli/models/extensions/schemas.tsassets: zod.string().optional()Checklist
patchfor bug fixes ·minorfor new features ·majorfor breaking changes) and added a changeset withpnpm changeset add