[workers-utils] Use the inherited Worker name for containers in named environments - #15009
Open
LeSingh1 wants to merge 1 commit into
Open
[workers-utils] Use the inherited Worker name for containers in named environments#15009LeSingh1 wants to merge 1 commit into
LeSingh1 wants to merge 1 commit into
Conversation
…amed environments `containers` is a non-inheritable field, but the Worker `name` it derives its default container name from is inheritable. `normalizeAndValidateEnvironment` passed `rawEnv.name` into `validateContainerApp`, which is `undefined` for any named environment that does not redeclare `name`. The result was a spurious `Must have either a top level "name" and "containers.class_name" field defined` error for a configuration that does set a top level `name`, and a generated container name of `undefined-<class_name>-<env>`. Fall back to the top level raw `name` so the generated name matches the documented `worker_name-class_name[-env_name]` default, while still letting an environment-level `name` take precedence.
🦋 Changeset detectedLatest commit: f34eb92 The changes in this PR will be included in the next version bump. This PR includes changesets to release 6 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 |
workers-devprod
requested review from
a team and
NuroDev
and removed request for
a team
August 4, 2026 04:03
Contributor
|
Codeowners approval required for this PR:
Show detailed file reviewers
|
@cloudflare/autoconfig
@cloudflare/build-output-utils
@cloudflare/config
create-cloudflare
@cloudflare/deploy-helpers
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-functions
@cloudflare/pages-shared
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-pool-workers
@cloudflare/workers-auth
@cloudflare/workers-editor-shared
@cloudflare/workers-utils
wrangler
commit: |
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.
normalizeAndValidateEnvironmentpassesrawEnv.nametovalidateContainerApp, butnameis inheritable. A named environment that doesn't redeclare it still runs under the top level Worker name, so the container name gets built fromundefined:{ "name": "test-worker-name", "env": { "staging": { "containers": [{ "image": "./Dockerfile", "class_name": "test-class" }] } } }On
mainthis produces"name": "undefined-test-class-staging"and then fails validation outright:Config errors are fatal (
packages/wrangler/src/config/index.tsthrowsUserError), so this blockswrangler deploy --env <name>entirely for any Worker declaringcontainersunder a named environment without repeatingname.Falling back to the top level name yields
"test-worker-name-test-class-staging"and validation passes. Nothing that previously succeeded changes behavior — this only unblocks a case that could not get past validation at all.name; no user-facing config surface changes.Note
This is a contribution from an AI agent: Claude Code (Claude Opus 4.5), working on behalf of @LeSingh1. Review comments will be read and responded to.