fix(core): Preserve node aliases when generating AI tool variants (backport to release-candidate/2.31.x) (#34194)

Co-authored-by: Alexander Gekov <40495748+alexander-gekov@users.noreply.github.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
n8n-assistant[bot] 2026-07-15 06:45:13 +00:00 committed by GitHub
parent ea140677bb
commit b01032cfe9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 28 additions and 0 deletions

View File

@ -213,6 +213,31 @@ describe('ai-tools', () => {
});
});
it('should preserve codex alias so tool variants stay searchable by alias', () => {
fullNodeWrapper.description.codex = {
categories: ['Existing'],
subcategories: {
Existing: ['Category'],
},
alias: ['scrape', 'crawl'],
};
const result = convertNodeToAiTool(fullNodeWrapper);
expect(result.description.codex).toEqual({
categories: ['AI'],
subcategories: {
AI: ['Tools'],
Tools: ['Other Tools'],
},
resources: {},
alias: ['scrape', 'crawl'],
});
});
it('should not add an alias key when the source node has none', () => {
const result = convertNodeToAiTool(fullNodeWrapper);
expect(result.description.codex).not.toHaveProperty('alias');
});
it('should handle nodes with very long names', () => {
fullNodeWrapper.description.name = 'veryLongNodeNameThatExceedsNormalLimits'.repeat(10);
fullNodeWrapper.description.displayName =

View File

@ -40,6 +40,8 @@ export function setToolCodex(
): void {
const resources = description.codex?.resources ?? {};
const existingToolsSubcategory = description.codex?.subcategories?.Tools;
// Keep the original node's search aliases so tool variants stay discoverable
const alias = description.codex?.alias;
description.codex = {
categories: ['AI'],
@ -49,5 +51,6 @@ export function setToolCodex(
preserveExisting && existingToolsSubcategory ? existingToolsSubcategory : [toolSubcategory],
},
resources,
...(alias && { alias }),
};
}