Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/fix-mixed-r2-buckets.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"miniflare": patch
---

fix: allow mixed `r2Buckets` records containing both string and object entries

Previously, passing an `r2Buckets` config that mixed plain string values and object entries (e.g. `{ MY_BUCKET: "bucket-name", OTHER_BUCKET: { ... } }`) would cause Miniflare to throw an error. Both forms are now accepted and normalised correctly.
16 changes: 9 additions & 7 deletions packages/miniflare/src/plugins/r2/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,16 @@ import {
export const R2OptionsSchema = z.object({
r2Buckets: z
.union([
z.record(z.string()),
z.record(
z.object({
id: z.string(),
remoteProxyConnectionString: z
.custom<RemoteProxyConnectionString>()
.optional(),
})
z.union([
z.string(),
z.object({
id: z.string(),
remoteProxyConnectionString: z
.custom<RemoteProxyConnectionString>()
.optional(),
}),
])
),
z.string().array(),
])
Expand Down
12 changes: 12 additions & 0 deletions packages/miniflare/test/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,18 @@ test("Miniflare: validates options", async ({ expect }) => {
);
});

test("Miniflare: accepts mixed r2Buckets record", () => {
const mf = new Miniflare({
modules: true,
script: "",
r2Buckets: {
LOCAL_BUCKET: "local-bucket",
REMOTE_BUCKET: { id: "remote-bucket" },
},
});
useDispose(mf);
});

test("Miniflare: ready returns copy of entry URL", async ({ expect }) => {
const mf = new Miniflare({
port: 0,
Expand Down
Loading