Skip to content

[workers-utils] Report a non-array queues.consumers as a config error instead of crashing - #15010

Open
LeSingh1 wants to merge 1 commit into
cloudflare:mainfrom
LeSingh1:fix/queues-consumers-not-array
Open

[workers-utils] Report a non-array queues.consumers as a config error instead of crashing#15010
LeSingh1 wants to merge 1 commit into
cloudflare:mainfrom
LeSingh1:fix/queues-consumers-not-array

Conversation

@LeSingh1

@LeSingh1 LeSingh1 commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

validateQueues pushes the "should be an array" diagnostic for a non-array queues.consumers, but then iterates the value anyway — there is no else or early return. The diagnostic it just prepared never reaches the user.

With consumers: null:

TypeError: Cannot read properties of null (reading 'length')
    at src/config/validation.ts:5116

With consumers: "my-queue" the string is iterated character by character, so the real error is buried under one spurious diagnostic per character:

- The field "queues.consumers" should be an array but got "my-queue".
- "queues.consumers[0]" should be a objects, but got "m".
- "queues.consumers[1]" should be a objects, but got "y".
... (6 more)

Guarding the loop behind the array check lets the intended diagnostic surface on its own.


  • Tests
    • Tests included/updated
  • Public documentation
    • Documentation not necessary because: this corrects validation error reporting only; no config surface or API 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

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

changeset-bot Bot commented Aug 4, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 8fdfa9c

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 jamesopstad 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/queues-consumers-not-array.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 found 1 potential issue.

Open in Devin Review

Comment on lines +5 to +9
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.

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.

🟡 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").

Suggested change
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.
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

@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@15010

@cloudflare/build-output-utils

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

@cloudflare/config

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

create-cloudflare

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

@cloudflare/deploy-helpers

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

@cloudflare/kv-asset-handler

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

miniflare

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

@cloudflare/pages-functions

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

@cloudflare/pages-shared

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

@cloudflare/unenv-preset

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

@cloudflare/vite-plugin

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

@cloudflare/vitest-pool-workers

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

@cloudflare/workers-auth

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

@cloudflare/workers-editor-shared

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

@cloudflare/workers-utils

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

wrangler

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

commit: 8fdfa9c

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