[wrangler] add validation to redirected configs in regards to environments#8596
Conversation
🦋 Changeset detectedLatest commit: eabdbf7 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
f51b420 to
06b83c9
Compare
06b83c9 to
31466bf
Compare
|
A wrangler prerelease is available for testing. You can install this latest build in your project with: npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14271950047/npm-package-wrangler-8596You can reference the automatically updated head of this PR with: npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/prs/8596/npm-package-wrangler-8596Or you can use npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14271950047/npm-package-wrangler-8596 dev path/to/script.jsAdditional artifacts:cloudflare-workers-bindings-extension: wget https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14271950047/npm-package-cloudflare-workers-bindings-extension-8596 -O ./cloudflare-workers-bindings-extension.0.0.0-vd08c4fc84.vsix && code --install-extension ./cloudflare-workers-bindings-extension.0.0.0-vd08c4fc84.vsixcreate-cloudflare: npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14271950047/npm-package-create-cloudflare-8596 --no-auto-update@cloudflare/kv-asset-handler: npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14271950047/npm-package-cloudflare-kv-asset-handler-8596miniflare: npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14271950047/npm-package-miniflare-8596@cloudflare/pages-shared: npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14271950047/npm-package-cloudflare-pages-shared-8596@cloudflare/unenv-preset: npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14271950047/npm-package-cloudflare-unenv-preset-8596@cloudflare/vite-plugin: npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14271950047/npm-package-cloudflare-vite-plugin-8596@cloudflare/vitest-pool-workers: npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14271950047/npm-package-cloudflare-vitest-pool-workers-8596@cloudflare/workers-editor-shared: npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14271950047/npm-package-cloudflare-workers-editor-shared-8596@cloudflare/workers-shared: npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14271950047/npm-package-cloudflare-workers-shared-8596@cloudflare/workflows-shared: npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14271950047/npm-package-cloudflare-workflows-shared-8596Note that these links will no longer work once the GitHub Actions artifact expires.
Please ensure constraints are pinned, and |
|
Pages doesn't really support environments and even shows errors when they are used: So I don't think that adding tests for this for the pages commands is necessary here 🤔 |
0c2b095 to
4a1748a
Compare
8caffe9 to
cca92dc
Compare
cca92dc to
8cbe58d
Compare
emily-shen
left a comment
There was a problem hiding this comment.
this would be great to get in!
| const definedEnvironments = Object.keys(rawConfig.env ?? {}); | ||
|
|
||
| if (isRedirectedConfig && definedEnvironments.length > 0) { | ||
| diagnostics.errors.push( |
There was a problem hiding this comment.
is there any way for the user to resolve this? or is this a build tool problem?
There was a problem hiding this comment.
is it a build tool problem, build tools should not generate configs containing environments 😕
yeah if a user were to get this there wouldn't be much they could do about it 😕
There was a problem hiding this comment.
Perhaps we should ask them to contact the maker of the tool that generated the redirected file?
8cbe58d to
66f711a
Compare
emily-shen
left a comment
There was a problem hiding this comment.
lock file seems to be broken though
Co-authored-by: emily-shen <[email protected]>
Co-authored-by: James Opstad <[email protected]>
d010e40 to
bb5fa7d
Compare
lock file fixed 🫡 |
| expect(text).toMatchInlineSnapshot(`"Generated: true"`); | ||
| }); | ||
|
|
||
| it("specifying an environment cause an error since they are supported in redirected configs", async ({ |
There was a problem hiding this comment.
| it("specifying an environment cause an error since they are supported in redirected configs", async ({ | |
| it("specifying an environment causes an error since they are not supported in redirected configs", async ({ |
| const definedEnvironments = Object.keys(rawConfig.env ?? {}); | ||
|
|
||
| if (isRedirectedConfig && definedEnvironments.length > 0) { | ||
| diagnostics.errors.push( |
There was a problem hiding this comment.
Perhaps we should ask them to contact the maker of the tool that generated the redirected file?
…onments #8596) (#8600) * [wrangler] add validation to redirected configs in regards to environments * error instead of warning on specified environments * Update packages/wrangler/src/config/validation.ts Co-authored-by: emily-shen <[email protected]> * Update packages/wrangler/src/config/validation.ts Co-authored-by: James Opstad <[email protected]> * update lock file * update fixture tests * update lock file --------- Co-authored-by: Dario Piotrowicz <[email protected]> Co-authored-by: emily-shen <[email protected]> Co-authored-by: James Opstad <[email protected]>
Fixes #8359
This PR adds the following validation behaviors to wrangler deploy commands, that relate
to redirected configs (i.e. config files specified by
.wrangler/deploy/config.jsonfiles):environment (i.e. a build tool should generate redirected configs already targeting specific
environments), so if wrangler encounters a redirected config with some environments defined
it should error
--env=my-env) when using redirectedconfigs is incorrect, so these environments should be ignored and a warning should be
presented to the user