Skip to content

[workers-utils] Use the inherited Worker name for containers in named environments - #15009

Open
LeSingh1 wants to merge 1 commit into
cloudflare:mainfrom
LeSingh1:fix/container-name-named-env
Open

[workers-utils] Use the inherited Worker name for containers in named environments#15009
LeSingh1 wants to merge 1 commit into
cloudflare:mainfrom
LeSingh1:fix/container-name-named-env

Conversation

@LeSingh1

@LeSingh1 LeSingh1 commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

normalizeAndValidateEnvironment passes rawEnv.name to validateContainerApp, but name is inheritable. A named environment that doesn't redeclare it still runs under the top level Worker name, so the container name gets built from undefined:

{
  "name": "test-worker-name",
  "env": {
    "staging": {
      "containers": [{ "image": "./Dockerfile", "class_name": "test-class" }]
    }
  }
}

On main this produces "name": "undefined-test-class-staging" and then fails validation outright:

Processing wrangler configuration:
  - "env.staging" environment configuration
    - Must have either a top level "name" and "containers.class_name" field defined, or have field "containers.name" defined.

Config errors are fatal (packages/wrangler/src/config/index.ts throws UserError), so this blocks wrangler deploy --env <name> entirely for any Worker declaring containers under a named environment without repeating name.

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.


  • Tests
    • Tests included/updated
  • Public documentation
    • Documentation not necessary because: this restores the documented inheritance behavior for 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.


Open in Devin Review

…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-bot

changeset-bot Bot commented Aug 4, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f34eb92

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

This PR includes changesets to release 6 packages
Name Type
@cloudflare/workers-utils Patch
@cloudflare/autoconfig Patch
@cloudflare/cli-shared-helpers Patch
@cloudflare/deploy-helpers Patch
@cloudflare/remote-bindings Patch
@cloudflare/workers-auth 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

@github-project-automation github-project-automation Bot moved this to Untriaged in workers-sdk Aug 4, 2026
@workers-devprod
workers-devprod requested review from a team and NuroDev and removed request for a team August 4, 2026 04:03
@workers-devprod

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • @cloudflare/wrangler
Show detailed file reviewers
  • .changeset/container-name-named-env.md: [@cloudflare/wrangler]
  • packages/workers-utils/src/config/validation.ts: [@cloudflare/wrangler]
  • packages/workers-utils/tests/config/validation/normalize-and-validate-config.test.ts: [@cloudflare/wrangler]

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 1 additional finding.

Open in Devin Review

@pkg-pr-new

pkg-pr-new Bot commented Aug 4, 2026

Copy link
Copy Markdown
@cloudflare/autoconfig

npm i https://pkg.pr.new/@cloudflare/autoconfig@15009

@cloudflare/build-output-utils

npm i https://pkg.pr.new/@cloudflare/build-output-utils@15009

@cloudflare/config

npm i https://pkg.pr.new/@cloudflare/config@15009

create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@15009

@cloudflare/deploy-helpers

npm i https://pkg.pr.new/@cloudflare/deploy-helpers@15009

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@15009

miniflare

npm i https://pkg.pr.new/miniflare@15009

@cloudflare/pages-functions

npm i https://pkg.pr.new/@cloudflare/pages-functions@15009

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@15009

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@15009

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@15009

@cloudflare/vitest-pool-workers

npm i https://pkg.pr.new/@cloudflare/vitest-pool-workers@15009

@cloudflare/workers-auth

npm i https://pkg.pr.new/@cloudflare/workers-auth@15009

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@15009

@cloudflare/workers-utils

npm i https://pkg.pr.new/@cloudflare/workers-utils@15009

wrangler

npm i https://pkg.pr.new/wrangler@15009

commit: f34eb92

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Untriaged

Development

Successfully merging this pull request may close these issues.

2 participants