diff --git a/packages/nodes-base/nodes/Set/Set.node.ts b/packages/nodes-base/nodes/Set/Set.node.ts index 8fb1c7e76f26c..17b2404ffb9a8 100644 --- a/packages/nodes-base/nodes/Set/Set.node.ts +++ b/packages/nodes-base/nodes/Set/Set.node.ts @@ -12,13 +12,14 @@ export class Set extends VersionedNodeType { icon: 'fa:pen', group: ['input'], description: 'Add or edit fields on an input item and optionally remove other fields', - defaultVersion: 3, + defaultVersion: 3.1, }; const nodeVersions: IVersionedNodeType['nodeVersions'] = { 1: new SetV1(baseDescription), 2: new SetV1(baseDescription), 3: new SetV2(baseDescription), + 3.1: new SetV2(baseDescription), }; super(nodeVersions, baseDescription); diff --git a/packages/nodes-base/nodes/Set/v2/SetV2.node.ts b/packages/nodes-base/nodes/Set/v2/SetV2.node.ts index 64955720911e0..5a9f92ef776d5 100644 --- a/packages/nodes-base/nodes/Set/v2/SetV2.node.ts +++ b/packages/nodes-base/nodes/Set/v2/SetV2.node.ts @@ -21,7 +21,7 @@ const versionDescription: INodeTypeDescription = { name: 'set', icon: 'fa:pen', group: ['input'], - version: 3, + version: [3, 3.1], description: 'Change the structure of your items', subtitle: '={{$parameter["mode"]}}', defaults: { diff --git a/packages/nodes-base/nodes/Set/v2/helpers/utils.ts b/packages/nodes-base/nodes/Set/v2/helpers/utils.ts index 3aca848519127..03e946f750cdf 100644 --- a/packages/nodes-base/nodes/Set/v2/helpers/utils.ts +++ b/packages/nodes-base/nodes/Set/v2/helpers/utils.ts @@ -159,13 +159,26 @@ export const validateEntry = ( node: INode, itemIndex: number, ignoreErrors = false, + nodeVersion?: number, ) => { let entryValue = entry[entry.type]; const name = entry.name; const entryType = entry.type.replace('Value', '') as FieldType; + const description = `To fix the error try to change the type for the field "${name}" or activate the option “Ignore Type Conversion Errors” to apply a less strict type validation`; + if (entryType === 'string') { - if (typeof entryValue === 'object') { + if (nodeVersion && nodeVersion > 3 && (entryValue === undefined || entryValue === null)) { + if (ignoreErrors) { + return { name, value: null }; + } else { + throw new NodeOperationError( + node, + `'${name}' expects a ${entryType} but we got '${String(entryValue)}' [item ${itemIndex}]`, + { description }, + ); + } + } else if (typeof entryValue === 'object') { entryValue = JSON.stringify(entryValue); } else { entryValue = String(entryValue); @@ -179,7 +192,6 @@ export const validateEntry = ( validationResult.newValue = entry[entry.type]; } else { const message = `${validationResult.errorMessage} [item ${itemIndex}]`; - const description = `To fix the error try to change the type for the field "${name}" or activate the option “Ignore Type Conversion Errors” to apply a less strict type validation`; throw new NodeOperationError(node, message, { itemIndex, description, diff --git a/packages/nodes-base/nodes/Set/v2/manual.mode.ts b/packages/nodes-base/nodes/Set/v2/manual.mode.ts index 6185ab90e7e3f..3e34973080edc 100644 --- a/packages/nodes-base/nodes/Set/v2/manual.mode.ts +++ b/packages/nodes-base/nodes/Set/v2/manual.mode.ts @@ -191,7 +191,13 @@ export async function execute( ); } - const { name, value } = validateEntry(entry, node, i, options.ignoreConversionErrors); + const { name, value } = validateEntry( + entry, + node, + i, + options.ignoreConversionErrors, + node.typeVersion, + ); newData[name] = value; }