feat: Better error when calling expression function on input that is undefined or null (#10009)

This commit is contained in:
Michael Kret
2024-07-11 15:36:39 +03:00
committed by GitHub
parent e3c138ffd2
commit 519e57bda5
7 changed files with 56 additions and 16 deletions

View File

@@ -6,6 +6,7 @@ import type {
INodeTypeBaseDescription,
INodeTypeDescription,
} from 'n8n-workflow';
import { ENABLE_LESS_STRICT_TYPE_VALIDATION } from '../../../utils/constants';
export class IfV2 implements INodeType {
description: INodeTypeDescription;
@@ -79,12 +80,8 @@ export class IfV2 implements INodeType {
extractValue: true,
}) as boolean;
} catch (error) {
if (!options.looseTypeValidation) {
set(
error,
'description',
"Try changing the type of comparison. Alternatively you can enable 'Less Strict Type Validation' in the options.",
);
if (!options.looseTypeValidation && !error.description) {
set(error, 'description', ENABLE_LESS_STRICT_TYPE_VALIDATION);
}
set(error, 'context.itemIndex', itemIndex);
set(error, 'node', this.getNode());