fix: saving an automation after its expiry passed fails with "The expiry time is in the past." (#35400)

The first save on an automation's page cut its expiry down to the minute, so an expiry the model had set, like "in 2 hours", moved up to a minute earlier, and if it had already passed by that first save, every edit was refused, even just a rename. An expiry left untouched now stays exactly as it was stored, and only a newly picked one is checked.

Fixes #35395
This commit is contained in:
Classic298 authored and GitHub committed 2026-12-01 00:26:39 +04:00
1 parent beed6b130e
commit 636dd45c30
2 files changed
+12 -5

No files matched your search

@@ -439,6 +439,9 @@ async def update_automation_by_id(
raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, detail=str(e))
await check_automation_limits(None, user, schedule.rrule, db)
# Browsers round nanosecond timestamps, so an expiry within a millisecond of the stored one is unchanged.
if form_data.expires_at and automation.expires_at and abs(form_data.expires_at - automation.expires_at) < 1_000_000:
form_data.expires_at = automation.expires_at
next_run_at = await schedule_next_run(form_data.data.model_dump(), tz=await get_owner_timezone(automation, user))
# An unchanged expiry, even a passed one, doesn't block other edits.
if form_data.expires_at != automation.expires_at:
@@ -157,6 +157,9 @@
let webhookAllowGet = false;
// A local date and time, as the datetime input holds it; empty means it never expires.
let expiresAt = '';
$: savedExpiresAt = automation.expires_at
? dayjs(automation.expires_at / 1_000_000).format('YYYY-MM-DDTHH:mm')
: '';
$: allowWebhook = !!$config?.features?.enable_automation_webhooks;
$: hookUrl = getAutomationHookUrl(automation);
let saving = false;
@@ -217,10 +220,7 @@
automation.data.triggers.some(
(trigger) => trigger.type === 'webhook' && !!trigger.allow_get
)) ||
expiresAt !==
(automation.expires_at
? dayjs(automation.expires_at / 1_000_000).format('YYYY-MM-DDTHH:mm')
: ''));
expiresAt !== savedExpiresAt);
// Agent models depend on the chosen machine, as in the automation modal.
let modelRequest = 0;
@@ -297,7 +297,11 @@
},
meta: automation.meta ?? undefined,
is_active,
expires_at: expiresAt ? dayjs(expiresAt).valueOf() * 1_000_000 : null
expires_at: expiresAt
? expiresAt === savedExpiresAt
? automation.expires_at
: dayjs(expiresAt).valueOf() * 1_000_000
: null
};
await updateAutomationById(localStorage.token, automation.id, form);
await editSavedHandler();