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

@@ -12,6 +12,7 @@ import type {
import { NodeConnectionType, NodeOperationError } from 'n8n-workflow';
import set from 'lodash/set';
import { capitalize } from '@utils/utilities';
import { ENABLE_LESS_STRICT_TYPE_VALIDATION } from '../../../utils/constants';
const configuredOutputs = (parameters: INodeParameters) => {
const mode = parameters.mode as string;
@@ -348,9 +349,8 @@ export class SwitchV3 implements INodeType {
},
) as boolean;
} catch (error) {
if (!options.looseTypeValidation) {
error.description =
"Try changing the type of comparison. Alternatively you can enable 'Less Strict Type Validation' in the options.";
if (!options.looseTypeValidation && !error.description) {
error.description = ENABLE_LESS_STRICT_TYPE_VALIDATION;
}
set(error, 'context.itemIndex', itemIndex);
set(error, 'node', this.getNode());