Skip to content

Commit f8516dd

Browse files
[miniflare] Fix mixed pipelines records (#12987)
1 parent 09b3028 commit f8516dd

3 files changed

Lines changed: 34 additions & 13 deletions

File tree

.changeset/fix-mixed-pipelines.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"miniflare": patch
3+
---
4+
5+
fix: allow mixed `pipelines` records containing both string and object entries
6+
7+
Previously, passing a `pipelines` config that mixed plain string values and object entries (e.g. `{ MY_PIPELINE: "pipeline-name", OTHER_PIPELINE: { pipeline: "...", remoteProxyConnectionString: ... } }`) would cause Miniflare to throw an error. Both forms are now accepted and normalised correctly.

packages/miniflare/src/plugins/pipelines/index.ts

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,18 @@ import {
1212
export const PipelineOptionsSchema = z.object({
1313
pipelines: z
1414
.union([
15-
z.record(z.string()),
16-
z.string().array(),
1715
z.record(
18-
z.object({
19-
pipeline: z.string(),
20-
remoteProxyConnectionString: z
21-
.custom<RemoteProxyConnectionString>()
22-
.optional(),
23-
})
16+
z.union([
17+
z.string(),
18+
z.object({
19+
pipeline: z.string(),
20+
remoteProxyConnectionString: z
21+
.custom<RemoteProxyConnectionString>()
22+
.optional(),
23+
}),
24+
])
2425
),
26+
z.string().array(),
2527
])
2628
.optional(),
2729
});
@@ -76,13 +78,13 @@ function bindingEntries(
7678
namespaces?:
7779
| Record<
7880
string,
79-
{
80-
pipeline: string;
81-
remoteProxyConnectionString?: RemoteProxyConnectionString;
82-
}
81+
| string
82+
| {
83+
pipeline: string;
84+
remoteProxyConnectionString?: RemoteProxyConnectionString;
85+
}
8386
>
8487
| string[]
85-
| Record<string, string>
8688
): [
8789
bindingName: string,
8890
{ id: string; remoteProxyConnectionString?: RemoteProxyConnectionString },

packages/miniflare/test/index.spec.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,18 @@ test("Miniflare: accepts mixed d1Databases record", () => {
172172
});
173173
useDispose(mf);
174174
});
175+
176+
test("Miniflare: accepts mixed pipelines record", () => {
177+
const mf = new Miniflare({
178+
modules: true,
179+
script: "",
180+
pipelines: {
181+
LOCAL_PIPELINE: "local-pipeline",
182+
REMOTE_PIPELINE: { pipeline: "remote-pipeline" },
183+
},
184+
});
185+
useDispose(mf);
186+
});
175187
test("Miniflare: ready returns copy of entry URL", async ({ expect }) => {
176188
const mf = new Miniflare({
177189
port: 0,

0 commit comments

Comments
 (0)