fix: Prevent error when importing nodes with malformed collection params (#17580)

This commit is contained in:
oleg
2025-07-24 09:40:10 +02:00
committed by GitHub
parent f30cc7b6cf
commit 4713827813
2 changed files with 102 additions and 0 deletions

View File

@@ -835,6 +835,10 @@ export function getNodeParameters(
// Multiple can be set so will be an array
const tempArrayValue: INodeParameters[] = [];
// Collection values should always be an object
if (typeof propertyValues !== 'object' || Array.isArray(propertyValues)) {
continue;
}
// Iterate over all items as it contains multiple ones
for (const nodeValue of (propertyValues as INodeParameters)[
itemName

View File

@@ -3416,6 +3416,104 @@ describe('NodeHelpers', () => {
},
},
},
{
description:
'fixedCollection with multipleValues: true - skip when propertyValues is not an object or is an array',
input: {
nodePropertiesArray: [
{
displayName: 'Values',
name: 'values',
type: 'fixedCollection',
typeOptions: {
multipleValues: true,
},
default: {},
options: [
{
name: 'option1',
displayName: 'Option 1',
values: [
{
displayName: 'String',
name: 'string1',
type: 'string',
default: 'default string',
},
],
},
],
},
],
nodeValues: {
// This simulates when propertyValues is incorrectly set as an array instead of an object
values: [] as any,
},
},
output: {
noneDisplayedFalse: {
defaultsFalse: {},
defaultsTrue: {
values: {},
},
},
noneDisplayedTrue: {
defaultsFalse: {},
defaultsTrue: {
values: {},
},
},
},
},
{
description:
'fixedCollection with multipleValues: true - skip when propertyValues is a string',
input: {
nodePropertiesArray: [
{
displayName: 'Values',
name: 'values',
type: 'fixedCollection',
typeOptions: {
multipleValues: true,
},
default: {},
options: [
{
name: 'option1',
displayName: 'Option 1',
values: [
{
displayName: 'String',
name: 'string1',
type: 'string',
default: 'default string',
},
],
},
],
},
],
nodeValues: {
// This simulates when propertyValues is incorrectly set as a string
values: 'invalid value' as any,
},
},
output: {
noneDisplayedFalse: {
defaultsFalse: {},
defaultsTrue: {
values: {},
},
},
noneDisplayedTrue: {
defaultsFalse: {},
defaultsTrue: {
values: {},
},
},
},
},
];
for (const testData of tests) {