chore(core): Allow undefined in the node output value (#18198)

This commit is contained in:
Guillaume Jacquart
2025-08-11 15:25:52 +02:00
committed by GitHub
parent 409085e8fe
commit 660f2ff09b
3 changed files with 40 additions and 52 deletions

View File

@@ -37,7 +37,7 @@
"optimize-svg": "find ./packages -name '*.svg' ! -name 'pipedrive.svg' -print0 | xargs -0 -P16 -L20 npx svgo",
"setup-backend-module": "node scripts/ensure-zx.mjs && zx scripts/backend-module/setup.mjs",
"start": "run-script-os",
"start:default": "cd packages/cli/bin && ./n8n",
"start:default": "cd packages/cli/bin && node --inspect ./n8n",
"start:tunnel": "./packages/cli/bin/n8n start --tunnel",
"start:windows": "cd packages/cli/bin && n8n",
"test": "JEST_JUNIT_CLASSNAME={filepath} turbo run test",

View File

@@ -99,12 +99,6 @@ describe('isJsonCompatible', () => {
errorPath: 'value.nan',
errorMessage: 'is NaN, which is not JSON-compatible',
},
{
name: 'undefined',
value: { undefined },
errorPath: 'value.undefined',
errorMessage: 'is of unknown type (undefined) with value undefined',
},
{
name: 'an object with symbol keys',
value: { [Symbol.for('key')]: 1 },
@@ -125,6 +119,7 @@ describe('isJsonCompatible', () => {
const objectRef = {};
test.each([
{ name: 'null', value: { null: null } },
{ name: 'undefined', value: { noValue: undefined } },
{ name: 'an array of primitives', value: { array: [1, 'string', true, false] } },
{
name: 'an object without a prototype chain',

View File

@@ -1,3 +1,4 @@
// eslint-disable-next-line complexity
const check = (
val: unknown,
path = 'value',
@@ -6,7 +7,7 @@ const check = (
): { isValid: true } | { isValid: false; errorPath: string; errorMessage: string } => {
const type = typeof val;
if (val === null || type === 'boolean' || type === 'string') {
if (val === null || type === 'boolean' || type === 'string' || type === 'undefined') {
return { isValid: true };
}
@@ -46,7 +47,6 @@ const check = (
return { isValid: true };
}
if (type === 'object') {
if (stack.has(val)) {
return {
isValid: false,
@@ -85,13 +85,6 @@ const check = (
}
stack.delete(val);
return { isValid: true };
}
return {
isValid: false,
errorPath: path,
errorMessage: `is of unknown type (${type}) with value ${JSON.stringify(val)}`,
};
};
/**