Skip to content

Fix json serialization but in mapWorkerMetadataBindings and add missing unit tests#14084

Open
dario-piotrowicz wants to merge 2 commits into
mainfrom
dario/DEVX-2344/constructWranglerConfig-test-coverage
Open

Fix json serialization but in mapWorkerMetadataBindings and add missing unit tests#14084
dario-piotrowicz wants to merge 2 commits into
mainfrom
dario/DEVX-2344/constructWranglerConfig-test-coverage

Conversation

@dario-piotrowicz
Copy link
Copy Markdown
Member

@dario-piotrowicz dario-piotrowicz commented May 28, 2026

Fixes https://jira.cfdata.org/browse/DEVX-2344

This PR adds fixes mapWorkerMetadataBindings not correctly mapping json bindings and it also adds test coverage for the makeWorkerConfig and mapWorkerMetadataBindings utilities


  • Tests
    • Tests included/updated
    • Automated tests not possible - manual testing has been completed as follows:
    • Additional testing not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: adding unit tests

A picture of a cute animal (not mandatory, but encouraged)

ask-bonk[bot]

This comment was marked as resolved.

@ask-bonk
Copy link
Copy Markdown
Contributor

ask-bonk Bot commented May 28, 2026

Review posted successfully. Here's a summary of my findings:

One actionable issue found:

The test for the json binding type in map-worker-metadata-bindings.test.ts (lines 43-60) asserts behavior that appears to be a pre-existing bug in the source code. The json case in mapWorkerMetadataBindings uses literal keys name and json instead of a computed property key [binding.name]: binding.json (which is the pattern used by the plain_text case). The test codifies this buggy behavior without any comment, which could mislead future readers into thinking it's intentional. I posted a suggestion to either fix both the source and the test together, or add a comment documenting the known-broken behavior.

github run

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 28, 2026

create-cloudflare

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

@cloudflare/deploy-helpers

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

@cloudflare/kv-asset-handler

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

miniflare

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

@cloudflare/pages-shared

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

@cloudflare/unenv-preset

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

@cloudflare/vite-plugin

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

@cloudflare/vitest-pool-workers

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

@cloudflare/workers-editor-shared

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

@cloudflare/workers-utils

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

wrangler

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

commit: 12a4692

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 28, 2026

🦋 Changeset detected

Latest commit: 12a4692

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

This PR includes changesets to release 2 packages
Name Type
@cloudflare/workers-utils Patch
@cloudflare/cli-shared-helpers 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-actions
Copy link
Copy Markdown
Contributor

✅ All changesets look good

@dario-piotrowicz dario-piotrowicz changed the title Add unit tests for workers-utils' makeWorkerConfig and mapWorkerMetadataBindings functions Fix json serialization but in mapWorkerMetadataBindings and add missing unit tests May 28, 2026
@dario-piotrowicz dario-piotrowicz marked this pull request as ready for review May 28, 2026 23:06
@workers-devprod workers-devprod requested review from a team and petebacondarwin and removed request for a team May 28, 2026 23:06
@workers-devprod
Copy link
Copy Markdown
Contributor

workers-devprod commented May 28, 2026

Codeowners approval required for this PR:

  • ✅ @cloudflare/wrangler
Show detailed file reviewers

Copy link
Copy Markdown
Contributor

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

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 3 additional findings.

Open in Devin Review

Copy link
Copy Markdown
Contributor

@petebacondarwin petebacondarwin left a comment

Choose a reason for hiding this comment

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

Has this been broken for a long time??

expect(result.main).toBe("index.js");
});

it("accepts an array with one worker", ({ expect }) => {
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.

Should it also accept multiple workers?

Copy link
Copy Markdown
Contributor

@workers-devprod workers-devprod left a comment

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 May 29, 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.

3 participants