Bugfix/Concatenate overrideconfig array (#4720)

concatenate overrideconfig array
This commit is contained in:
Henry Heng 2025-06-24 21:59:56 +01:00 committed by GitHub
parent 3f26569e6e
commit d5bc718246
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 36 additions and 18 deletions

View File

@ -1135,7 +1135,13 @@ export const replaceInputsWithConfig = (
} else if (Array.isArray(overrideConfig[config])) { } else if (Array.isArray(overrideConfig[config])) {
// Handle arrays as direct parameter values // Handle arrays as direct parameter values
if (isParameterEnabled(flowNodeData.label, config)) { if (isParameterEnabled(flowNodeData.label, config)) {
inputsObj[config] = overrideConfig[config] // If existing value is also an array, concatenate; otherwise replace
const existingValue = inputsObj[config]
if (Array.isArray(existingValue)) {
inputsObj[config] = [...new Set([...existingValue, ...overrideConfig[config]])]
} else {
inputsObj[config] = overrideConfig[config]
}
} }
continue continue
} else if (overrideConfig[config] && typeof overrideConfig[config] === 'object') { } else if (overrideConfig[config] && typeof overrideConfig[config] === 'object') {
@ -1168,24 +1174,36 @@ export const replaceInputsWithConfig = (
const overrideConfigValue = overrideConfig[config] const overrideConfigValue = overrideConfig[config]
if (overrideConfigValue) { if (overrideConfigValue) {
if (typeof overrideConfigValue === 'object') { if (typeof overrideConfigValue === 'object') {
switch (typeof paramValue) { // Handle arrays specifically - concatenate instead of replace
case 'string': if (Array.isArray(overrideConfigValue) && Array.isArray(paramValue)) {
if (paramValue.startsWith('{') && paramValue.endsWith('}')) { paramValue = [...new Set([...paramValue, ...overrideConfigValue])]
try { } else if (Array.isArray(overrideConfigValue)) {
paramValue = Object.assign({}, JSON.parse(paramValue), overrideConfigValue) paramValue = overrideConfigValue
break } else {
} catch (e) { switch (typeof paramValue) {
// ignore case 'string':
if (paramValue.startsWith('{') && paramValue.endsWith('}')) {
try {
paramValue = Object.assign({}, JSON.parse(paramValue), overrideConfigValue)
break
} catch (e) {
// ignore
}
} }
} paramValue = overrideConfigValue
paramValue = overrideConfigValue break
break case 'object':
case 'object': // Make sure we're not dealing with arrays here
paramValue = Object.assign({}, paramValue, overrideConfigValue) if (!Array.isArray(paramValue)) {
break paramValue = Object.assign({}, paramValue, overrideConfigValue)
default: } else {
paramValue = overrideConfigValue paramValue = overrideConfigValue
break }
break
default:
paramValue = overrideConfigValue
break
}
} }
} else { } else {
paramValue = overrideConfigValue paramValue = overrideConfigValue