mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
fix(Set Node): Do not stringify null and undefined (#7313)
Github issue / Community forum post (link here to close automatically): https://community.n8n.io/t/null-and-undefined-in-string-fields/31060/1
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user