Skip to content

fix(miniflare): allow mixed r2Buckets records (#1)#11789

Closed
shellscape wants to merge 2 commits intocloudflare:mainfrom
charlie-labs:main
Closed

fix(miniflare): allow mixed r2Buckets records (#1)#11789
shellscape wants to merge 2 commits intocloudflare:mainfrom
charlie-labs:main

Conversation

@shellscape
Copy link
Copy Markdown

@shellscape shellscape commented Jan 4, 2026

Fix Miniflare's R2 options validation so r2Buckets can be a single record containing mixed entry shapes:

  • local bucket names as string
  • remote bucket references as { id, remoteProxyConnectionString? }

Why this change is needed

Miniflare supports both local and remote R2 bindings, and downstream tooling may generate a single r2Buckets record containing a mix of both shapes.

For example, a tool can reasonably create Miniflare options like:

import { Miniflare } from "miniflare";

const mf = new Miniflare({
  script: "",
  modules: true,
  r2Buckets: {
    // local bucket (just a bucket name)
    LOCAL_BUCKET: "local-bucket",

    // remote bucket (R2 binding via remote proxy)
    REMOTE_BUCKET: {
      id: "remote-bucket",
      // optional: remoteProxyConnectionString: "..."
    },
  },
});

Before this change, r2Buckets could be:

  • a record of strings (Record<string, string>), or
  • a record of objects (Record<string, { id; remoteProxyConnectionString? }>), or
  • an array of bucket names (string[])

…but a mixed record would fail validation (because Zod would pick one record schema and then reject entries of the other shape). The runtime already normalizes values on a per-entry basis (via namespaceEntries()), so the stricter validation was blocking a configuration that Miniflare can already interpret correctly.

Note: While this work was done with the assistance of @CharlieHelps, it was reviewed and tested locally via package patch by actual humans (me, @shellscape). No slop here.


  • Tests
    • Tests included/updated
    • Tests not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: internal validation change; no doc updates required

cuteness



Open with Devin

* 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>
@shellscape shellscape requested a review from a team as a code owner January 4, 2026 04:07
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Jan 4, 2026

⚠️ No Changeset found

Latest commit: 48b49cc

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@shellscape
Copy link
Copy Markdown
Author

dropping a comment here to prevent it from going stale

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.

This change looks good. It still needs a changeset, and looks like it has a rebase conflict that needs resolving.

@github-project-automation github-project-automation bot moved this from Untriaged to In Review in workers-sdk Jan 26, 2026
@petebacondarwin petebacondarwin added the miniflare Relating to Miniflare label Jan 26, 2026
@petebacondarwin petebacondarwin moved this from In Review to In Progress in workers-sdk Jan 26, 2026
@shellscape
Copy link
Copy Markdown
Author

@petebacondarwin thanks, on it.

# Conflicts:
#	packages/miniflare/test/index.spec.ts
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 flags.

Open in Devin Review

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Jan 27, 2026

create-cloudflare

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

@cloudflare/kv-asset-handler

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

miniflare

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

@cloudflare/pages-shared

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

@cloudflare/unenv-preset

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

@cloudflare/vite-plugin

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

@cloudflare/vitest-pool-workers

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

@cloudflare/workers-editor-shared

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

@cloudflare/workers-utils

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

wrangler

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

commit: 48b49cc

@petebacondarwin
Copy link
Copy Markdown
Contributor

I've rebased this PR on main, ported the test to vitest style (from ava), and added the missing changeset. Since I don't have push access to your fork, the updated branch is at pbacondarwin/fix-mixed-r2-buckets on the main repo. If you'd like to pull these changes into your fork, or we can create a new PR from that branch.

@petebacondarwin petebacondarwin added the awaiting reporter response Needs clarification or followup from OP label Mar 16, 2026
@petebacondarwin
Copy link
Copy Markdown
Contributor

Thank you for this contribution! The fix is correct and we'd like to get it merged. Since we weren't able to push the necessary updates (rebase, vitest migration, changeset) to your fork branch, we've moved this to an internal branch and will merge from there. The new PR is linked below. Thanks again for identifying and fixing this issue!

@github-project-automation github-project-automation bot moved this from In Progress to Done in workers-sdk Mar 18, 2026
@shellscape
Copy link
Copy Markdown
Author

@petebacondarwin im currently on vacation with my family. Thanks for taking this over. I don't see the PR link yet but I'll keep an eye out for it

@petebacondarwin
Copy link
Copy Markdown
Contributor

Yeah sorry I forgot to press "go" on the new PR...

#12952

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

Labels

awaiting reporter response Needs clarification or followup from OP miniflare Relating to Miniflare

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants