fix(Wait Node): Prevent waiting until invalid date (#10523)

This commit is contained in:
Iván Ovejero 2024-08-27 16:45:08 +02:00 committed by GitHub
parent fd58a272e1
commit c0e7620036
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -7,7 +7,7 @@ import type {
IDisplayOptions,
IWebhookFunctions,
} from 'n8n-workflow';
import { WAIT_TIME_UNLIMITED } from 'n8n-workflow';
import { WAIT_TIME_UNLIMITED, NodeOperationError } from 'n8n-workflow';
import {
authenticationProperty,
@ -346,6 +346,7 @@ export class Wait extends Webhook {
},
default: '',
description: 'The date and time to wait for before continuing',
required: true,
},
// ----------------------------------
@ -492,6 +493,13 @@ export class Wait extends Webhook {
} else {
const dateTimeStr = context.getNodeParameter('dateTime', 0) as string;
if (isNaN(Date.parse(dateTimeStr))) {
throw new NodeOperationError(
context.getNode(),
'[Wait node] Cannot put execution to wait because `dateTime` parameter is not a valid date. Please pick a specific date and time to wait until.',
);
}
waitTill = DateTime.fromFormat(dateTimeStr, "yyyy-MM-dd'T'HH:mm:ss", {
zone: context.getTimezone(),
})