Cron: guard missing expr in schedule parsing

This commit is contained in:
Vignesh Natarajan
2026-02-21 20:18:11 -08:00
parent eea0a68199
commit 961bde27fe
6 changed files with 45 additions and 2 deletions

View File

@@ -186,4 +186,19 @@ describe("cron schedule error isolation", () => {
expect(badJob.state.lastError).toMatch(/^schedule error:/);
expect(badJob.state.lastError).toBeTruthy();
});
it("records a clear schedule error when cron expr is missing", () => {
const badJob = createJob({
id: "missing-expr",
name: "Missing Expr",
schedule: { kind: "cron" } as unknown as CronJob["schedule"],
});
const state = createMockState([badJob]);
recomputeNextRuns(state);
expect(badJob.state.lastError).toContain("invalid cron schedule: expr is required");
expect(badJob.state.lastError).not.toContain("Cannot read properties of undefined");
expect(badJob.state.scheduleErrorCount).toBe(1);
});
});