Skip to content

Commit febdfa7

Browse files
JoseBraclaude
andcommitted
fix(ai-builder): Remove unnecessary list() call from conflict handler (no-changelog)
The conflict error already tells us the table exists — no need to verify with list(). The extra call could fail and re-throw the original error, defeating the fix. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 26d532a commit febdfa7

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

packages/@n8n/instance-ai/src/tools/data-tables/__tests__/create-data-table.tool.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,6 @@ describe('createCreateDataTableTool', () => {
169169
(wrappedError as Error & { cause: Error }).cause = conflictError;
170170

171171
(context.dataTableService.create as jest.Mock).mockRejectedValue(wrappedError);
172-
(context.dataTableService.list as jest.Mock).mockResolvedValue([mockTable]);
173172

174173
const tool = createCreateDataTableTool(context);
175174

packages/@n8n/instance-ai/src/tools/data-tables/create-data-table.tool.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,16 +112,12 @@ export function createCreateDataTableTool(context: InstanceAiContext) {
112112
return { table };
113113
} catch (error) {
114114
// If table already exists, guide the agent to use the existing one
115-
// rather than throwing — which would cause the agent to retry in a loop
115+
// rather than throwing — which would cause the agent to waste iterations retrying
116116
if (isNameConflictError(error)) {
117-
const tables = await context.dataTableService.list({ projectId: input.projectId });
118-
const existing = tables.find((t) => t.name === input.name);
119-
if (existing) {
120-
return {
121-
denied: true,
122-
reason: `Table "${input.name}" already exists. Use list-data-tables to find it and get-data-table-schema to check its columns.`,
123-
};
124-
}
117+
return {
118+
denied: true,
119+
reason: `Table "${input.name}" already exists. Use list-data-tables to find it and get-data-table-schema to check its columns.`,
120+
};
125121
}
126122
throw error;
127123
}

0 commit comments

Comments
 (0)