fix(mothership): workflow name constraints#3710
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Greptile SummaryThis PR adds a duplicate workflow-name constraint to Key findings:
Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Client
participant API as /api/workflows (POST)
participant Copilot as Copilot Tool Executor
participant CWR as createWorkflowRecord()
participant DB as Database
Note over Client,DB: Direct API path (pre-existing check)
Client->>API: POST /api/workflows {name, folderId}
API->>DB: SELECT id WHERE name+folder match
DB-->>API: duplicate? → 409 Conflict
API->>DB: INSERT workflow (if no duplicate)
Note over Client,DB: Copilot path (new check added by this PR)
Client->>Copilot: create_workflow tool call {name, folderId}
Copilot->>CWR: createWorkflowRecord(params)
CWR->>DB: SELECT id WHERE name+folder match
DB-->>CWR: duplicate? → throw Error
CWR-->>Copilot: {success: false, error: message}
CWR->>DB: INSERT workflow (if no duplicate)
|
| throw new Error( | ||
| `A workflow named "${name}" already exists in this folder. Use a different name.` | ||
| ) |
There was a problem hiding this comment.
Misleading error message when no folder is selected
When folderId is null the workflow is at the workspace root, not inside a folder. The error message "already exists in this folder" is incorrect in that case — it should say "already exists in this workspace" (or "in the root") to avoid confusing users who didn't select any folder.
| throw new Error( | |
| `A workflow named "${name}" already exists in this folder. Use a different name.` | |
| ) | |
| throw new Error( | |
| folderId | |
| ? `A workflow named "${name}" already exists in this folder. Use a different name.` | |
| : `A workflow named "${name}" already exists in this workspace. Use a different name.` | |
| ) |
The same wording issue also exists in the already-present check in apps/sim/app/api/workflows/route.ts at line 237.
Summary
Block duplicate workflow names
Type of Change
Testing
Manual
Checklist