Skip to content

Commit 94a4ff8

Browse files
committed
fix bool env var coercion
1 parent bcf8b2e commit 94a4ff8

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

apps/supervisor/src/env.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@ import { randomUUID } from "crypto";
22
import { env as stdEnv } from "std-env";
33
import { z } from "zod";
44

5+
const BoolEnv = z.preprocess((val) => {
6+
if (typeof val !== "string") {
7+
return val;
8+
}
9+
10+
return ["true", "1"].includes(val.toLowerCase().trim());
11+
}, z.boolean());
12+
513
const Env = z.object({
614
// This will come from `spec.nodeName` in k8s
715
TRIGGER_WORKER_INSTANCE_NAME: z.string().default(randomUUID()),
@@ -12,7 +20,7 @@ const Env = z.object({
1220
MANAGED_WORKER_SECRET: z.string(),
1321

1422
// Workload API settings (coordinator mode) - the workload API is what the run controller connects to
15-
TRIGGER_WORKLOAD_API_ENABLED: z.coerce.boolean().default(true),
23+
TRIGGER_WORKLOAD_API_ENABLED: BoolEnv.default("true"),
1624
TRIGGER_WORKLOAD_API_PROTOCOL: z
1725
.string()
1826
.transform((s) => z.enum(["http", "https"]).parse(s.toLowerCase()))
@@ -22,7 +30,7 @@ const Env = z.object({
2230
TRIGGER_WORKLOAD_API_PORT_EXTERNAL: z.coerce.number().default(8020), // This is the exposed port passed to the run controller
2331

2432
// Dequeue settings (provider mode)
25-
TRIGGER_DEQUEUE_ENABLED: z.coerce.boolean().default(true),
33+
TRIGGER_DEQUEUE_ENABLED: BoolEnv.default("true"),
2634
TRIGGER_DEQUEUE_INTERVAL_MS: z.coerce.number().int().default(1000),
2735

2836
// Optional services

0 commit comments

Comments
 (0)