[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 2 commits into
Conversation
🦋 Changeset detectedLatest commit: 48f0137 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 |
@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: |
`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`.
8fdfa9c to
05178f3
Compare
|
Hi. We are not accepting PRs that don't have an associated issue. Please could you open an issue with a reproduction first. Thanks. |
|
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. |
|
Issue with reproduction: #15069 |
Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
dario-piotrowicz
left a comment
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
Codeowners reviews satisfied
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.