Skip to content

Commit 0b28b7f

Browse files
committed
fix(supervisor): reject an empty toleration value
An empty value after "=" parses as an exact match on a valueless taint, which is legal but almost never what was meant. A templated value that resolved empty produced a toleration that matched nothing, so the supervisor started and every run pod stayed pending. The error names the Exists form for anyone who did mean it.
1 parent af73c53 commit 0b28b7f

2 files changed

Lines changed: 17 additions & 3 deletions

File tree

apps/supervisor/src/envUtil.test.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,15 @@ describe("Tolerations", () => {
120120
]);
121121
});
122122

123-
it("should keep an empty value as an exact match for a valueless taint", () => {
124-
expect(Tolerations.parse("dedicated=:NoSchedule")).toEqual([
125-
{ key: "dedicated", operator: "Equal", value: "", effect: "NoSchedule" },
123+
it("should reject an empty value, and point at the Exists form instead", () => {
124+
const result = Tolerations.safeParse("dedicated=:NoSchedule");
125+
expect(result.success).toBe(false);
126+
expect(result.error?.issues[0]?.message).toBe(
127+
'Invalid toleration format (empty value): "dedicated=:NoSchedule". Drop the "=" to tolerate any value of "dedicated".'
128+
);
129+
130+
expect(Tolerations.parse("dedicated:NoSchedule")).toEqual([
131+
{ key: "dedicated", operator: "Exists", effect: "NoSchedule" },
126132
]);
127133
});
128134

apps/supervisor/src/envUtil.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,14 @@ export const Tolerations = z.string().transform((val, ctx) => {
122122
}
123123

124124
const value = keyValue.slice(eqIdx + 1).trim();
125+
if (!value) {
126+
ctx.addIssue({
127+
code: z.ZodIssueCode.custom,
128+
message: `Invalid toleration format (empty value): "${entry}". Drop the "=" to tolerate any value of "${key}".`,
129+
});
130+
return z.NEVER;
131+
}
132+
125133
if (!isLabelValue(value)) {
126134
ctx.addIssue({
127135
code: z.ZodIssueCode.custom,

0 commit comments

Comments
 (0)