mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-16 09:36:44 +00:00
fix: Prevent error when importing nodes with malformed collection params (#17580)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user