From 6af9c5a7b8fd4f3437f972f6cd7e7db67fa36c27 Mon Sep 17 00:00:00 2001 From: Nicolas Meienberger Date: Mon, 22 Dec 2025 19:46:47 +0100 Subject: [PATCH] refactor: guard against potential undefined cron expression --- .../modules/backups/components/create-schedule-form.tsx | 2 +- app/client/modules/backups/lib/cron-utils.ts | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/client/modules/backups/components/create-schedule-form.tsx b/app/client/modules/backups/components/create-schedule-form.tsx index 1e6f2edb..1d94ff17 100644 --- a/app/client/modules/backups/components/create-schedule-form.tsx +++ b/app/client/modules/backups/components/create-schedule-form.tsx @@ -83,7 +83,7 @@ const backupScheduleToFormValues = (schedule?: BackupSchedule): InternalFormValu return undefined; } - const cronValues = cronToFormValues(schedule.cronExpression); + const cronValues = cronToFormValues(schedule.cronExpression ?? "0 * * * *"); const patterns = schedule.includePatterns || []; const isGlobPattern = (p: string) => /[*?[\]]/.test(p); diff --git a/app/client/modules/backups/lib/cron-utils.ts b/app/client/modules/backups/lib/cron-utils.ts index a7bcf2f8..71d881ea 100644 --- a/app/client/modules/backups/lib/cron-utils.ts +++ b/app/client/modules/backups/lib/cron-utils.ts @@ -77,6 +77,10 @@ const matchers: Matcher[] = [ ]; export const cronToFormValues = (cronExpression: string): CronFormValues => { + if (!cronExpression) { + return { frequency: "hourly" }; + } + const normalized = cronExpression.trim().replace(/\s+/g, " "); const parts = normalized.split(" ");