Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wrangler] add validation to redirected configs in regards to environments #8596

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dario-piotrowicz
Copy link
Member

@dario-piotrowicz dario-piotrowicz commented Mar 20, 2025

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.json files):

  • redirected configs are supposed to be already flattened configurations without any
    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
  • given the point above, specifying an environment (--env=my-env) when using redirected
    configs is incorrect, so these environments should be ignored and a warning should be
    presented to the user

@dario-piotrowicz dario-piotrowicz requested a review from a team as a code owner March 20, 2025 16:35
Copy link

changeset-bot bot commented Mar 20, 2025

🦋 Changeset detected

Latest commit: 8cbe58d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
wrangler Patch
@cloudflare/vitest-pool-workers Patch

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

@dario-piotrowicz dario-piotrowicz force-pushed the dario/8359/wrangler/redirected-config-env branch from f51b420 to 06b83c9 Compare March 20, 2025 16:36
@dario-piotrowicz dario-piotrowicz force-pushed the dario/8359/wrangler/redirected-config-env branch from 06b83c9 to 31466bf Compare March 20, 2025 17:57
Copy link
Contributor

github-actions bot commented Mar 20, 2025

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/14058778816/npm-package-wrangler-8596

You 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-8596

Or you can use npx with this latest build directly:

npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14058778816/npm-package-wrangler-8596 dev path/to/script.js
Additional artifacts:

cloudflare-workers-bindings-extension:

wget https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14058778816/npm-package-cloudflare-workers-bindings-extension-8596 -O ./cloudflare-workers-bindings-extension.0.0.0-v9b064942a.vsix && code --install-extension ./cloudflare-workers-bindings-extension.0.0.0-v9b064942a.vsix

create-cloudflare:

npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14058778816/npm-package-create-cloudflare-8596 --no-auto-update

@cloudflare/kv-asset-handler:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14058778816/npm-package-cloudflare-kv-asset-handler-8596

miniflare:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14058778816/npm-package-miniflare-8596

@cloudflare/pages-shared:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14058778816/npm-package-cloudflare-pages-shared-8596

@cloudflare/unenv-preset:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14058778816/npm-package-cloudflare-unenv-preset-8596

@cloudflare/vite-plugin:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14058778816/npm-package-cloudflare-vite-plugin-8596

@cloudflare/vitest-pool-workers:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14058778816/npm-package-cloudflare-vitest-pool-workers-8596

@cloudflare/workers-editor-shared:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14058778816/npm-package-cloudflare-workers-editor-shared-8596

@cloudflare/workers-shared:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14058778816/npm-package-cloudflare-workers-shared-8596

@cloudflare/workflows-shared:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14058778816/npm-package-cloudflare-workflows-shared-8596

Note that these links will no longer work once the GitHub Actions artifact expires.


[email protected] includes the following runtime dependencies:

Package Constraint Resolved
miniflare workspace:* 4.20250320.0
workerd 1.20250321.0 1.20250321.0
workerd --version 1.20250321.0 2025-03-21

Please ensure constraints are pinned, and miniflare/workerd minor versions match.

@dario-piotrowicz
Copy link
Member Author

Pages doesn't really support environments and even shows errors when they are used:

"Pages does not support targeting an environment with the --env flag. Use the --branch flag to target your production or preview branch",

So I don't think that adding tests for this for the pages commands is necessary here 🤔

@dario-piotrowicz dario-piotrowicz added the e2e Run wrangler e2e tests on a PR label Mar 20, 2025
@dario-piotrowicz dario-piotrowicz force-pushed the dario/8359/wrangler/redirected-config-env branch 3 times, most recently from 0c2b095 to 4a1748a Compare March 21, 2025 11:00
@dario-piotrowicz dario-piotrowicz requested a review from a team as a code owner March 21, 2025 11:05
@dario-piotrowicz dario-piotrowicz force-pushed the dario/8359/wrangler/redirected-config-env branch 3 times, most recently from 8caffe9 to cca92dc Compare March 25, 2025 10:47
@dario-piotrowicz dario-piotrowicz force-pushed the dario/8359/wrangler/redirected-config-env branch from cca92dc to 8cbe58d Compare March 25, 2025 11:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
e2e Run wrangler e2e tests on a PR
Projects
Status: Untriaged
Development

Successfully merging this pull request may close these issues.

🐛 BUG: env in redirected configs
1 participant