mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 02:21:13 +00:00
fix(core): Use manual tool description if neither resources or operations exist (#15093)
This commit is contained in:
@@ -68,6 +68,15 @@ describe('createNodeAsTool', () => {
|
||||
|
||||
expect(tool.description).toBe('Custom tool description');
|
||||
});
|
||||
|
||||
it('should use toolDescription when descriptionType is absent', () => {
|
||||
delete node.parameters.descriptionType;
|
||||
node.parameters.toolDescription = 'Another custom tool description';
|
||||
|
||||
const tool = createNodeAsTool(options).response;
|
||||
|
||||
expect(tool.description).toBe('Another custom tool description');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Schema Creation and Parameter Handling', () => {
|
||||
|
||||
@@ -90,8 +90,6 @@ function getSchema(node: INode) {
|
||||
* @returns A string description for the node.
|
||||
*/
|
||||
function makeDescription(node: INode, nodeType: INodeType): string {
|
||||
const manualDescription = node.parameters.toolDescription as string;
|
||||
|
||||
if (node.parameters.descriptionType === 'auto') {
|
||||
const resource = node.parameters.resource as string;
|
||||
const operation = node.parameters.operation as string;
|
||||
@@ -104,11 +102,10 @@ function makeDescription(node: INode, nodeType: INodeType): string {
|
||||
}
|
||||
return description.trim();
|
||||
}
|
||||
if (node.parameters.descriptionType === 'manual') {
|
||||
return manualDescription ?? nodeType.description.description;
|
||||
}
|
||||
|
||||
return nodeType.description.description;
|
||||
// Users can define custom descriptions when `descriptionType` is manual or not included
|
||||
// in the node's properties, e.g. when the node has neither `operation` or `resource`
|
||||
return (node.parameters.toolDescription as string) ?? nodeType.description.description;
|
||||
}
|
||||
|
||||
export function nodeNameToToolName(node: INode): string {
|
||||
|
||||
Reference in New Issue
Block a user