fix(schedules): ensure cronSchedule is always a string when removing jobs

- Updated the job removal logic to default cronSchedule to an empty string if job.pattern is undefined, preventing potential errors during job removal.
This commit is contained in:
Mauricio Siu
2026-02-07 01:42:14 -06:00
parent 26d4058457
commit 425bcf8958
3 changed files with 16 additions and 13 deletions
+4 -4
View File
@@ -47,25 +47,25 @@ app.post("/update-backup", zValidator("json", jobQueueSchema), async (c) => {
result = await removeJob({
backupId: data.backupId,
type: "backup",
cronSchedule: job.pattern,
cronSchedule: job.pattern || "",
});
} else if (data.type === "server") {
result = await removeJob({
serverId: data.serverId,
type: "server",
cronSchedule: job.pattern,
cronSchedule: job.pattern || "",
});
} else if (data.type === "schedule") {
result = await removeJob({
scheduleId: data.scheduleId,
type: "schedule",
cronSchedule: job.pattern,
cronSchedule: job.pattern || "",
});
} else if (data.type === "volume-backup") {
result = await removeJob({
volumeBackupId: data.volumeBackupId,
type: "volume-backup",
cronSchedule: job.pattern,
cronSchedule: job.pattern || "",
});
}
logger.info({ result }, "Job removed");