-
Notifications
You must be signed in to change notification settings - Fork 758
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
fix: ensure that non-inherited fields are not removed when using an inferred named environment #7478
Conversation
🦋 Changeset detectedLatest commit: 50f5b2e 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 |
I can confirm that the updated tests fail without this fix. |
env: { | ||
DEV: { | ||
account_id: "some_account_id", | ||
it("should error if named environment contains a `account_id` field, even if there is no top-level name", () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This whole section has just been moved inside the "non-legacy" describe block as that is what they are related to. There is no code change here.
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/12282151899/npm-package-wrangler-7478 You can reference the automatically updated head of this PR with: npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/prs/7478/npm-package-wrangler-7478 Or you can use npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/12282151899/npm-package-wrangler-7478 dev path/to/script.js Additional artifacts:npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/12282151899/npm-package-create-cloudflare-7478 --no-auto-update npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/12282151899/npm-package-cloudflare-kv-asset-handler-7478 npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/12282151899/npm-package-miniflare-7478 npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/12282151899/npm-package-cloudflare-pages-shared-7478 npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/12282151899/npm-package-cloudflare-vitest-pool-workers-7478 npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/12282151899/npm-package-cloudflare-workers-editor-shared-7478 npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/12282151899/npm-package-cloudflare-workers-shared-7478 npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/12282151899/npm-package-cloudflare-workflows-shared-7478 Note that these links will no longer work once the GitHub Actions artifact expires.
Please ensure constraints are pinned, and |
// `rawEnv === topLevelEnv` is a special case where the user has provided an environment name | ||
// but that named environment is not actually defined in the configuration. | ||
// In that case we have reused the topLevelEnv as the rawEnv, | ||
// and so we need to process the `transformFn()` anyway rather than just using the field in the `rawEnv`. | ||
(rawEnv !== topLevelEnv ? (rawEnv[field] as Environment[K]) : undefined) ?? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trying to understand the need for the extra logic here. What would happen if it was left as it was?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without this the inherited field transform does not run. For example the name
field gets transformed when it is inherited from 'my-worker' to 'my-worker-env'.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. Thanks!
80c4fc2
to
0d6a2f5
Compare
…nferred named environment It is an error for the the user to provide an environment name that doesn't match any of the named environments in the Wrangler configuration. But if there are no named environments defined at all in the Wrangler configuration, we special case the top-level environment as though it was a named environment. Previously, when this happens, we would remove all the nonInheritable fields from the configuration (essentially all the bindings) leaving an incorrect configuration. Now we correctly generate a flattened named environment that has the nonInheritable fields, plus correctly applies any transformFn on inheritable fields.
0d6a2f5
to
50f5b2e
Compare
…nferred named environment (#7478) It is an error for the the user to provide an environment name that doesn't match any of the named environments in the Wrangler configuration. But if there are no named environments defined at all in the Wrangler configuration, we special case the top-level environment as though it was a named environment. Previously, when this happens, we would remove all the nonInheritable fields from the configuration (essentially all the bindings) leaving an incorrect configuration. Now we correctly generate a flattened named environment that has the nonInheritable fields, plus correctly applies any transformFn on inheritable fields.
Fixes #0000
It is an error for the the user to provide an environment name that doesn't match any of the named environments in the Wrangler configuration. But if there are no named environments defined at all in the Wrangler configuration, we special case the top-level environment as though it was a named environment. Previously, when this happens, we would remove all the nonInheritable fields from the configuration (essentially all the bindings) leaving an incorrect configuration. Now we correctly generate a flattened named environment that has the nonInheritable fields, plus correctly applies any transformFn on inheritable fields.