[workers-utils] Report a non-array queues.consumers as a config error instead of crashing - #15010
[workers-utils] Report a non-array queues.consumers as a config error instead of crashing#15010LeSingh1 wants to merge 1 commit into
Conversation
`validateQueues` recorded the `should be an array` diagnostic for a non-array `queues.consumers` but then fell through to the `for` loop instead of stopping, so the diagnostic it had just prepared never reached the user. `"consumers": null` threw `TypeError: Cannot read properties of null (reading 'length')` out of config validation, and `"consumers": "my-queue"` iterated the string's characters, emitting one spurious `"queues.consumers[N]" should be a objects` error per character. Guard the loop behind the array check, matching `queues.producers`, which returns early via `validateBindingArray`.
🦋 Changeset detectedLatest commit: 8fdfa9c 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 |
|
Codeowners approval required for this PR:
Show detailed file reviewers
|
| Report a non-array `queues.consumers` as a configuration error instead of crashing | ||
|
|
||
| `validateQueues` pushed the `The field "queues.consumers" should be an array` diagnostic and then iterated the value anyway. `"queues": { "consumers": null }` therefore threw `TypeError: Cannot read properties of null (reading 'length')` before the diagnostic could be rendered, and `"queues": { "consumers": "my-queue" }` walked the string character by character, adding one bogus `"queues.consumers[0]" should be a objects, but got "m"` error per character on top of the real one. | ||
|
|
||
| The intended error is now the only thing reported, matching how the sibling `queues.producers` field already behaves. |
There was a problem hiding this comment.
🟡 Release note describes internal code details instead of user impact
The release note text describes internal function names and code flow (.changeset/queues-consumers-not-array.md:7-9) rather than the user-facing effect, which the repository's changeset guidelines forbid.
Impact: The published changelog entry will read like maintainer notes rather than something useful to people using the tools.
Which rules this conflicts with
REVIEW.md: "Changesets should target users of the tools (e.g. Wrangler users) rather than maintainers. Avoid including implementation details..." The body names the internal validator function validateQueues and describes how it "pushed the diagnostic and then iterated the value anyway". AGENTS.md also states changesets should "reference the public-facing package, not internal implementation packages", while this changeset only targets the internal @cloudflare/workers-utils package (its package.json describes it as "Internal utility package for workers-sdk. Not intended for external use").
| Report a non-array `queues.consumers` as a configuration error instead of crashing | |
| `validateQueues` pushed the `The field "queues.consumers" should be an array` diagnostic and then iterated the value anyway. `"queues": { "consumers": null }` therefore threw `TypeError: Cannot read properties of null (reading 'length')` before the diagnostic could be rendered, and `"queues": { "consumers": "my-queue" }` walked the string character by character, adding one bogus `"queues.consumers[0]" should be a objects, but got "m"` error per character on top of the real one. | |
| The intended error is now the only thing reported, matching how the sibling `queues.producers` field already behaves. | |
| Report an invalid `queues.consumers` value as a configuration error instead of crashing | |
| Previously, setting `queues.consumers` to something other than an array (for example `null` or a string) could crash Wrangler or produce a flood of confusing extra errors. You now get a single clear message telling you the field must be an array. |
Was this helpful? React with 👍 or 👎 to provide feedback.
@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: |
validateQueuespushes the "should be an array" diagnostic for a non-arrayqueues.consumers, but then iterates the value anyway — there is noelseor early return. The diagnostic it just prepared never reaches the user.With
consumers: null:With
consumers: "my-queue"the string is iterated character by character, so the real error is buried under one spurious diagnostic per character:Guarding the loop behind the array check lets the intended diagnostic surface on its own.
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.