Skip to content

fix(miniflare): allow mixed r2Buckets records#12952

Merged
petebacondarwin merged 3 commits into
mainfrom
pbacondarwin/fix-mixed-r2-buckets
Mar 20, 2026
Merged

fix(miniflare): allow mixed r2Buckets records#12952
petebacondarwin merged 3 commits into
mainfrom
pbacondarwin/fix-mixed-r2-buckets

Conversation

@petebacondarwin
Copy link
Copy Markdown
Contributor

Supersedes #11789 (original PR by @shellscape via charlie-labs fork). Moved to an internal branch to apply necessary updates (rebase, vitest test migration, changeset).

The R2OptionsSchema Zod validation previously required all values in an r2Buckets record to be either all strings or all objects. This prevented mixed records like:

r2Buckets: {
  LOCAL_BUCKET: "local-bucket",
  REMOTE_BUCKET: { id: "remote-bucket" },
}

The fix collapses the two separate z.record() branches into a single z.record(z.union([...])) so each value is validated independently. The runtime (namespaceEntries()) already supported mixed records — this brings the schema in line.


  • 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: Bug fix to existing behavior, no new API surface

@petebacondarwin petebacondarwin requested a review from a team as a code owner March 18, 2026 13:51
@petebacondarwin petebacondarwin added the miniflare Relating to Miniflare label Mar 18, 2026
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Mar 18, 2026

🦋 Changeset detected

Latest commit: aaf5769

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

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

@workers-devprod
Copy link
Copy Markdown
Contributor

workers-devprod commented Mar 18, 2026

Codeowners approval required for this PR:

  • ✅ @cloudflare/wrangler
Show detailed file reviewers

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 18, 2026

✅ All changesets look good

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Mar 18, 2026

create-cloudflare

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

@cloudflare/kv-asset-handler

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

miniflare

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

@cloudflare/pages-shared

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

@cloudflare/unenv-preset

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

@cloudflare/vite-plugin

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

@cloudflare/vitest-pool-workers

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

@cloudflare/workers-editor-shared

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

wrangler

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

commit: aaf5769

charliecreates Bot and others added 2 commits March 20, 2026 13:41
* fix(miniflare): allow mixed r2Buckets entries

* test(miniflare): strengthen mixed r2Buckets test

* test(miniflare): avoid double-fail in r2Buckets test

---------

Co-authored-by: CharlieHelps <charlie@charlielabs.ai>
@petebacondarwin petebacondarwin force-pushed the pbacondarwin/fix-mixed-r2-buckets branch from 09c7112 to e239b49 Compare March 20, 2026 13:41
Previously, passing an `r2Buckets` config that mixed plain string values and object entries would cause Miniflare to throw an error. Both forms are now accepted and normalised correctly.
@github-project-automation github-project-automation Bot moved this from Untriaged to Approved in workers-sdk Mar 20, 2026
@penalosa
Copy link
Copy Markdown
Contributor

Do other binding types have the same problem?

@petebacondarwin petebacondarwin merged commit 9c9fe30 into main Mar 20, 2026
46 of 47 checks passed
@petebacondarwin petebacondarwin deleted the pbacondarwin/fix-mixed-r2-buckets branch March 20, 2026 14:39
@github-project-automation github-project-automation Bot moved this from Approved to Done in workers-sdk Mar 20, 2026
@petebacondarwin
Copy link
Copy Markdown
Contributor Author

Do other binding types have the same problem?

@penalosa - I am investigating

@petebacondarwin
Copy link
Copy Markdown
Contributor Author

Do other binding types have the same problem?

@penalosa - I am investigating

These also need updating:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

miniflare Relating to Miniflare

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants