Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
…f looping (no-changelog) When the builder creates a workflow involving a data table, it creates the table in run #1 then tries to create it again in run #2 (rebuild phase). The DataTableNameConflictError causes the agent to retry in a loop until the build times out. Fix: catch the conflict error and return `denied: true` with a reason guiding the agent to use the existing table. The agent already handles denied responses gracefully. Before: BUILD FAILED after 175s of looping After: BUILD SUCCESS in ~3 min, 3/3 scenarios passing Ref: https://linear.app/n8n/issue/AI-2358 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
0ebd291 to
e25246c
Compare
…no-changelog) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
1 issue found across 2 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/@n8n/instance-ai/src/tools/data-tables/create-data-table.tool.ts">
<violation number="1" location="packages/@n8n/instance-ai/src/tools/data-tables/create-data-table.tool.ts:117">
P1: Convert `DataTableNameConflictError` to `denied: true` unconditionally. The extra `list()` check can still rethrow the conflict and recreate the retry loop described in AI-2358.</violation>
</file>
Architecture diagram
sequenceDiagram
participant Agent as AI Agent (Mastra)
participant Tool as Tool: create-data-table
participant Service as DataTableService
participant DB as Database
Note over Agent, DB: Request Flow: Data Table Creation
Agent->>Tool: execute(name, columns)
alt Permission: require_approval
Tool->>Agent: suspend(message)
Note over Agent, Tool: User approves action
Agent->>Tool: resume(approved: true)
else Permission: blocked
Tool-->>Agent: { denied: true, reason: "Action blocked" }
end
Note over Tool, Service: Execution Phase (CHANGED)
Tool->>Service: create(name, columns)
Service->>DB: INSERT INTO data_tables ...
alt Table Name Unique
DB-->>Service: Table Record
Service-->>Tool: table
Tool-->>Agent: { table }
else Table Name Conflict
DB-->>Service: Error (Unique Constraint)
Service-->>Tool: throw DataTableNameConflictError
Note over Tool: NEW: Handle conflict to prevent retry loop
Tool->>Service: list({ projectId })
Service->>DB: SELECT * FROM data_tables
DB-->>Service: existing tables
Service-->>Tool: tables
opt Table found in list
Tool-->>Agent: CHANGED: { denied: true, reason: "Table already exists..." }
Note right of Agent: Agent continues gracefully<br/>instead of retrying
end
else Other Error
Service-->>Tool: throw Error
Tool-->>Agent: Exception (Agent may retry)
end
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.
packages/@n8n/instance-ai/src/tools/data-tables/create-data-table.tool.ts
Outdated
Show resolved
Hide resolved
… (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>
OlegIvaniv
approved these changes
Apr 10, 2026
| */ | ||
| function isNameConflictError(error: unknown): boolean { | ||
| let current: unknown = error; | ||
| while (current instanceof Error) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
create-data-tabletool throwingDataTableNameConflictErrorwhen the table already exists during the builder's rebuild cycle, causing the agent to waste iterations retryingdenied: truewith guidance to use the existing table, which the agent handles gracefullyBefore / After
Context
Reported independently by product team — a user spent 45 min trying to build a workflow with a data table before giving up. The data table conflict during the builder's rebuild cycle wastes agent iterations and context, making it more likely to hit proxy timeouts.
Related Linear ticket
https://linear.app/n8n/issue/AI-2358
Review checklist
Test plan
🤖 Generated with Claude Code