Skip to content

Commit 450910e

Browse files
committed
Add validation guard for empty keys
1 parent 46521c5 commit 450910e

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

apps/supervisor/src/env.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,13 +196,22 @@ const Env = z
196196

197197
const keyValue = entry.slice(0, colonIdx);
198198
const eqIdx = keyValue.indexOf("=");
199+
const key = eqIdx === -1 ? keyValue : keyValue.slice(0, eqIdx);
200+
201+
if (!key) {
202+
ctx.addIssue({
203+
code: z.ZodIssueCode.custom,
204+
message: `Invalid toleration format (empty key): "${entry}"`,
205+
});
206+
return z.NEVER;
207+
}
199208

200209
if (eqIdx === -1) {
201-
return { key: keyValue, operator: "Exists" as const, effect };
210+
return { key, operator: "Exists" as const, effect };
202211
}
203212

204213
return {
205-
key: keyValue.slice(0, eqIdx),
214+
key,
206215
operator: "Equal" as const,
207216
value: keyValue.slice(eqIdx + 1),
208217
effect,

0 commit comments

Comments
 (0)