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