fix: an empty Custom schedule is saved as no schedule instead of being refused (#35387)

When the schedule was set to Custom and the rule left empty, Create and Save stored the automation with no schedule and without any error, so it never ran on its own. They now refuse it with "Invalid value: Custom schedule" and save nothing. The Create dialog also refuses a Once schedule set in the past again.

Fixes #35386
This commit is contained in:
Classic298 authored and GitHub committed 2026-11-30 23:35:13 +04:00
1 parent b3d6eb4f4a
commit 615ce0ccf1
2 files changed
+17 -6

No files matched your search

+14 -4
View File
@@ -106,6 +106,9 @@
// Schedule dropdown ref
let scheduleDropdown: ScheduleDropdown;
let scheduleFrequency: string;
let scheduleOnceDate: string;
let scheduleOnceTime: string;
let savedRrule = '';
$: allowWebhook = !!$config?.features?.enable_automation_webhooks;
@@ -118,12 +121,12 @@
toast.error($i18n.t('Channel is required'));
return;
}
if (scheduleDropdown.frequency === 'CUSTOM' && !scheduleDropdown.buildRrule().trim()) {
if (scheduleFrequency === 'CUSTOM' && !scheduleDropdown.buildRrule().trim()) {
toast.error($i18n.t('Invalid value') + ': ' + $i18n.t('Custom schedule'));
return;
}
if (scheduleDropdown?.frequency === 'ONCE') {
const scheduled = new Date(`${scheduleDropdown.onceDate}T${scheduleDropdown.onceTime}`);
if (scheduleFrequency === 'ONCE') {
const scheduled = new Date(`${scheduleOnceDate}T${scheduleOnceTime}`);
if (scheduled <= new Date()) {
toast.error($i18n.t('Scheduled time must be in the future'));
return;
@@ -335,7 +338,14 @@
class="flex flex-col sm:flex-row sm:items-center sm:justify-between px-4 pb-3.5 pt-1 gap-2"
>
<div class="flex items-center gap-0.5 flex-wrap min-w-0 sm:flex-1">
<ScheduleDropdown bind:this={scheduleDropdown} side="top" align="start" />
<ScheduleDropdown
bind:this={scheduleDropdown}
bind:frequency={scheduleFrequency}
bind:onceDate={scheduleOnceDate}
bind:onceTime={scheduleOnceTime}
side="top"
align="start"
/>
{#if allowWebhook || webhookEnabled}
<WebhookDropdown
@@ -149,7 +149,7 @@
let machines: MachineServer[] = [];
let agentModels: AgentModel[] = [];
// One row per schedule, and an empty one (None) when there is none.
let scheduleRows: { dropdown?: ScheduleDropdown }[] = [];
let scheduleRows: { dropdown?: ScheduleDropdown; frequency?: string }[] = [];
let scheduleTick = 0;
// The stored rules as the schedule fields rebuild them, so an untouched schedule is not a change.
let savedRrules: string[] = [];
@@ -257,7 +257,7 @@
return;
}
const rrules = scheduleRows.map((row) => row.dropdown?.buildRrule() ?? '');
if (scheduleRows.some((row, i) => row.dropdown?.frequency === 'CUSTOM' && !rrules[i].trim())) {
if (scheduleRows.some((row, i) => row.frequency === 'CUSTOM' && !rrules[i].trim())) {
toast.error($i18n.t('Invalid value') + ': ' + $i18n.t('Custom schedule'));
return;
}
@@ -745,6 +745,7 @@
<div class="min-w-0 flex-1" inert={!canManage || undefined}>
<ScheduleDropdown
bind:this={row.dropdown}
bind:frequency={row.frequency}
plain
side="bottom"
align="start"