Skip to content

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

Open
LeSingh1 wants to merge 2 commits 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 2 commits 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

@changeset-bot

changeset-bot Bot commented Aug 4, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 48f0137

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

workers-devprod commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • ✅ @cloudflare/wrangler
Show detailed file reviewers

devin-ai-integration[bot]

This comment was marked as resolved.

@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: 48f0137

`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`.
@jamesopstad

Copy link
Copy Markdown
Contributor

Hi. We are not accepting PRs that don't have an associated issue. Please could you open an issue with a reproduction first. Thanks.

@jamesopstad jamesopstad closed this Aug 6, 2026
@github-project-automation github-project-automation Bot moved this from Untriaged to Done in workers-sdk Aug 6, 2026
@LeSingh1

LeSingh1 commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

Understood, and sorry — I should have read CONTRIBUTING.md more carefully before opening these. I'll write up an issue with a reproduction and link it here.

I have five more fixes in this repo staged locally. I've stopped filing them; I'll open issues for those instead and wait, rather than send more PRs.

@LeSingh1

LeSingh1 commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

Issue with reproduction: #15069

Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>

@dario-piotrowicz dario-piotrowicz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you very much for the fix (and the issue and everything) @LeSingh1 🙂

I've accepted devin's changeset suggestion, besides that all else looks good to me 😄 💪

@workers-devprod workers-devprod 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.

Codeowners reviews satisfied

@github-project-automation github-project-automation Bot moved this from Untriaged to Approved in workers-sdk Aug 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Approved

Development

Successfully merging this pull request may close these issues.

A non-array queues.consumers crashes config validation with a TypeError instead of a config error

5 participants