mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 02:21:13 +00:00
fix: Remove parameter merging from node update tool of AI Builder (no-changelog) (#18476)
This commit is contained in:
@@ -192,7 +192,7 @@ describe('UpdateNodeParametersTool', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should merge parameters instead of replacing them', async () => {
|
it('should be able to remove parameters', async () => {
|
||||||
const existingWorkflow = createWorkflow([
|
const existingWorkflow = createWorkflow([
|
||||||
createNode({
|
createNode({
|
||||||
id: 'node1',
|
id: 'node1',
|
||||||
@@ -208,9 +208,10 @@ describe('UpdateNodeParametersTool', () => {
|
|||||||
]);
|
]);
|
||||||
setupWorkflowState(mockGetCurrentTaskInput, existingWorkflow);
|
setupWorkflowState(mockGetCurrentTaskInput, existingWorkflow);
|
||||||
|
|
||||||
// Mock chain response - only updating URL
|
// Mock chain response - removing authentication
|
||||||
mockChain.invoke.mockResolvedValue({
|
mockChain.invoke.mockResolvedValue({
|
||||||
parameters: {
|
parameters: {
|
||||||
|
method: 'GET',
|
||||||
url: 'https://api.example.com/v2',
|
url: 'https://api.example.com/v2',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -218,19 +219,17 @@ describe('UpdateNodeParametersTool', () => {
|
|||||||
const mockConfig = createToolConfig('update_node_parameters', 'test-call-3');
|
const mockConfig = createToolConfig('update_node_parameters', 'test-call-3');
|
||||||
|
|
||||||
const result = await updateNodeParametersTool.invoke(
|
const result = await updateNodeParametersTool.invoke(
|
||||||
buildUpdateNodeInput('node1', ['Update URL to v2 endpoint']),
|
buildUpdateNodeInput('node1', ['Update URL to v2 endpoint', 'Remove authentication']),
|
||||||
mockConfig,
|
mockConfig,
|
||||||
);
|
);
|
||||||
|
|
||||||
const content = parseToolResult<ParsedToolContent>(result);
|
const content = parseToolResult<ParsedToolContent>(result);
|
||||||
|
|
||||||
// Should keep existing parameters and only update URL
|
// Should remove authentication and keep other parameters
|
||||||
expectNodeUpdated(content, 'node1', {
|
expectNodeUpdated(content, 'node1', {
|
||||||
parameters: expect.objectContaining({
|
parameters: expect.objectContaining({
|
||||||
method: 'GET', // preserved
|
method: 'GET', // preserved
|
||||||
url: 'https://api.example.com/v2', // updated
|
url: 'https://api.example.com/v2', // updated
|
||||||
authentication: 'genericCredentialType', // preserved
|
|
||||||
genericAuthType: 'httpBasicAuth', // preserved
|
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ import {
|
|||||||
extractNodeParameters,
|
extractNodeParameters,
|
||||||
formatChangesForPrompt,
|
formatChangesForPrompt,
|
||||||
updateNodeWithParameters,
|
updateNodeWithParameters,
|
||||||
mergeParameters,
|
|
||||||
fixExpressionPrefixes,
|
fixExpressionPrefixes,
|
||||||
} from './utils/parameter-update.utils';
|
} from './utils/parameter-update.utils';
|
||||||
import type { UpdateNodeParametersOutput } from '../types/tools';
|
import type { UpdateNodeParametersOutput } from '../types/tools';
|
||||||
@@ -140,16 +139,12 @@ export function createUpdateNodeParametersTool(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Fix expression prefixes in the new parameters
|
// Fix expression prefixes in the new parameters
|
||||||
const fixedParameters = fixExpressionPrefixes(newParameters.parameters);
|
const fixedParameters = fixExpressionPrefixes(
|
||||||
|
newParameters.parameters,
|
||||||
// Merge the new parameters with existing ones
|
) as INodeParameters;
|
||||||
const updatedParameters = mergeParameters(
|
|
||||||
currentParameters,
|
|
||||||
fixedParameters as INodeParameters,
|
|
||||||
);
|
|
||||||
|
|
||||||
// Create updated node
|
// Create updated node
|
||||||
const updatedNode = updateNodeWithParameters(node, updatedParameters);
|
const updatedNode = updateNodeWithParameters(node, fixedParameters);
|
||||||
|
|
||||||
// Build success message
|
// Build success message
|
||||||
const message = buildSuccessMessage(node, changes);
|
const message = buildSuccessMessage(node, changes);
|
||||||
@@ -159,7 +154,7 @@ export function createUpdateNodeParametersTool(
|
|||||||
nodeId,
|
nodeId,
|
||||||
nodeName: node.name,
|
nodeName: node.name,
|
||||||
nodeType: node.type,
|
nodeType: node.type,
|
||||||
updatedParameters,
|
updatedParameters: fixedParameters,
|
||||||
appliedChanges: changes,
|
appliedChanges: changes,
|
||||||
message,
|
message,
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user