[Feature] Relative url patching on contract app extensions - #8362
[Feature] Relative url patching on contract app extensions#8362EliasJRH wants to merge 5 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR extends relative-URL support beyond locally-specified extensions by introducing shared URL resolution logic and applying it to contract-based modules (notably flow_trigger_lifecycle_callback), so relative URL fields can be resolved against the dev tunnel in app dev and against application_url during deploy.
Changes:
- Introduces
resolveAppRelativeUrl/patchAppRelativeUrlsto centralize “app-relative URL” resolution and validation (HTTPS-only, blocks protocol-relative URLs and control characters). - Applies the shared resolver to Flow action URL fields and to contract-based module config patching (dev + deploy).
- Adds/updates tests and a changeset documenting the new user-facing behavior.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/app/src/cli/services/flow/validation.ts | Reuses shared control-character regex for Flow action URL validation. |
| packages/app/src/cli/services/flow/utils.ts | Removes Flow-action-specific URL resolution helper (now centralized elsewhere). |
| packages/app/src/cli/services/flow/utils.test.ts | Removes tests for deleted resolveFlowActionUrl. |
| packages/app/src/cli/services/flow/types.ts | Removes now-unused FlowActionUrlField type. |
| packages/app/src/cli/models/extensions/specifications/validation/app_relative_urls.ts | Adds shared resolver/patcher for app-relative URLs and contract-module field mapping. |
| packages/app/src/cli/models/extensions/specifications/validation/app_relative_urls.test.ts | Adds unit coverage for the shared resolver/patcher behavior and error cases. |
| packages/app/src/cli/models/extensions/specifications/flow_action.ts | Switches Flow action URL resolution to shared resolveAppRelativeUrl. |
| packages/app/src/cli/models/extensions/specification.ts | Hooks contract-based modules into app-relative URL patching in dev + deploy paths. |
| packages/app/src/cli/models/extensions/specification.integration.test.ts | Adds integration coverage for contract-based module relative URL behavior. |
| packages/app/src/cli/models/app/validation/common.ts | Adds shared URL_CONTROL_CHARACTERS and isHttpsUrl helpers. |
| .changeset/flow-trigger-lifecycle-callback-relative-url.md | Declares the user-facing feature as a minor bump. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| // A contract based module has no local schema, so its configuration is deployed as authored. The exception is | ||
| // the app relative URL fields declared in app_relative_urls.ts: those are resolved against the dev tunnel here, | ||
| // and against the app's application_url in deployConfig below. | ||
| patchWithAppDevURLs: (config, urls) => { |
There was a problem hiding this comment.
Having a secondary registry for a subset of extension types hidden inside of patchWithAppDevURLs is surprising.
Have we considered making app-relative URL support an explicit capability of a specification instead of adding patchWithAppDevURLs to all contract-based modules and then filtering by identifier?
For example, createContractBasedModuleSpecification could accept appRelativeUrlFields, and a schema-less local flow_trigger_lifecycle_callback specification could enable it for url. The remote contract schema would still validate the configuration and we wouldn't need to supersede any config schema locally.
WHY are these changes introduced?
Part of https://github.com/shop/issues-automate/issues/3352
Merge only after https://meteorite.shopify.io/repos/shop/world/pulls/2009553/files has merged
WHAT is this pull request doing?
We recently extended
deployConfigwith the capabilities of using application config info (primarily the application url) when deploying app extensions with local contracts (see #7715). This PR primarily extends this to extensions with remote contracts (in this PR, the Flow trigger lifecycle callback extension time).How to test your changes?
Tested on flow-with-local-apps rig from
flowzone./realtive-path) with corresponding route file in/app/routesshopify app devcreate and activate a Flow workflow using custom Flow trigger, observe that relative route file is hit in application logsshopify app deploy, create and activate a Flow workflow using custom Flow trigger, observe that application url receives callback request at relative pathCI
dev test packages/app/src/cli/models/extensions/specifications/validation/app_relative_urls.test.ts packages/app/src/cli/models/extensions/specification.integration.test.ts packages/app/src/cli/services/flow/utils.test.ts-> 34 tests passPost-release steps
Will update "Flow trigger lifecycle callback" extension docs to include info about relative url support. Will also publish developer changelog entry.
Checklist