Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
2dd6d3d
fix(import): dedup workflow name (#3813)
icecrasher321 Mar 27, 2026
dda012e
feat(concurrency): bullmq based concurrency control system (#3605)
icecrasher321 Mar 27, 2026
271624a
fix(linear): add default null for after cursor (#3814)
icecrasher321 Mar 27, 2026
a7c1e51
fix(knowledge): reject non-alphanumeric file extensions from document…
waleedlatif1 Mar 27, 2026
c05e2e0
fix(security): SSRF, access control, and info disclosure (#3815)
waleedlatif1 Mar 28, 2026
21156dd
fix(worker): dockerfile + helm updates (#3818)
icecrasher321 Mar 28, 2026
33fdb11
update dockerfile (#3819)
icecrasher321 Mar 28, 2026
23c3072
fix dockerfile
icecrasher321 Mar 28, 2026
8f3e864
fix(security): pentest remediation — condition escaping, SSRF hardeni…
waleedlatif1 Mar 28, 2026
d2c3c1c
improvement(worker): configuration defaults (#3821)
icecrasher321 Mar 28, 2026
eac41ca
improvement(tour): remove auto-start, only trigger on explicit user a…
waleedlatif1 Mar 28, 2026
b4064c5
fix(mcp): use correct modal for creating workflow MCP servers in depl…
waleedlatif1 Mar 28, 2026
e4d3573
fix(knowledge): give users choice to keep or delete documents when re…
waleedlatif1 Mar 28, 2026
f6b461a
fix(readme): restore readme gifs (#3827)
waleedlatif1 Mar 28, 2026
e2be992
feat(academy): Sim Academy — interactive partner certification platfo…
waleedlatif1 Mar 28, 2026
edc5023
improvement(sidebar): expand sidebar by hovering and clicking the edg…
waleedlatif1 Mar 28, 2026
0ea7326
feat(ui): handle image paste (#3826)
TheodoreSpeaks Mar 28, 2026
7b0ce80
feat(files): interactive markdown checkbox toggling in preview (#3829)
waleedlatif1 Mar 28, 2026
d013132
improvement(home): position @ mention popup at caret and fix icon con…
waleedlatif1 Mar 28, 2026
30377d7
improvement(ui): sidebar (#3832)
waleedlatif1 Mar 28, 2026
f1ead2e
fix docker image build
icecrasher321 Mar 29, 2026
b9b930b
feat(analytics): add Profound web traffic tracking (#3835)
waleedlatif1 Mar 29, 2026
b371364
feat(resources): add sort and filter to all resource list pages (#3834)
waleedlatif1 Mar 29, 2026
336c065
fix(viewer): image pan/zoom, sort fixes, sidebar dot fixes (#3836)
waleedlatif1 Mar 29, 2026
82e58a5
fix(academy): hide academy pages until content is ready (#3839)
waleedlatif1 Mar 30, 2026
1728c37
improvement(landing): lighthouse performance and accessibility fixes …
waleedlatif1 Mar 30, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix(import): dedup workflow name (#3813)
  • Loading branch information
icecrasher321 authored Mar 27, 2026
commit 2dd6d3d1e6d0d303e15b429c33357d71b88c947d
76 changes: 42 additions & 34 deletions apps/sim/app/api/workflows/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { AuditAction, AuditResourceType, recordAudit } from '@/lib/audit/log'
import { checkSessionOrInternalAuth } from '@/lib/auth/hybrid'
import { generateRequestId } from '@/lib/core/utils/request'
import { getNextWorkflowColor } from '@/lib/workflows/colors'
import { listWorkflows, type WorkflowScope } from '@/lib/workflows/utils'
import { deduplicateWorkflowName, listWorkflows, type WorkflowScope } from '@/lib/workflows/utils'
import { getUserEntityPermissions, workspaceExists } from '@/lib/workspaces/permissions/utils'
import { verifyWorkspaceMembership } from '@/app/api/workflows/utils'

Expand All @@ -25,6 +25,7 @@ const CreateWorkflowSchema = z.object({
workspaceId: z.string().optional(),
folderId: z.string().nullable().optional(),
sortOrder: z.number().int().optional(),
deduplicate: z.boolean().optional(),
})

// GET /api/workflows - Get workflows for user (optionally filtered by workspaceId)
Expand Down Expand Up @@ -126,12 +127,13 @@ export async function POST(req: NextRequest) {
const body = await req.json()
const {
id: clientId,
name,
name: requestedName,
description,
color,
workspaceId,
folderId,
sortOrder: providedSortOrder,
deduplicate,
} = CreateWorkflowSchema.parse(body)

if (!workspaceId) {
Expand Down Expand Up @@ -162,19 +164,6 @@ export async function POST(req: NextRequest) {

logger.info(`[${requestId}] Creating workflow ${workflowId} for user ${userId}`)

import('@/lib/core/telemetry')
.then(({ PlatformEvents }) => {
PlatformEvents.workflowCreated({
workflowId,
name,
workspaceId: workspaceId || undefined,
folderId: folderId || undefined,
})
})
.catch(() => {
// Silently fail
})

let sortOrder: number
if (providedSortOrder !== undefined) {
sortOrder = providedSortOrder
Expand Down Expand Up @@ -214,31 +203,50 @@ export async function POST(req: NextRequest) {
sortOrder = minSortOrder != null ? minSortOrder - 1 : 0
}

const duplicateConditions = [
eq(workflow.workspaceId, workspaceId),
isNull(workflow.archivedAt),
eq(workflow.name, name),
]
let name = requestedName

if (folderId) {
duplicateConditions.push(eq(workflow.folderId, folderId))
if (deduplicate) {
name = await deduplicateWorkflowName(requestedName, workspaceId, folderId)
} else {
duplicateConditions.push(isNull(workflow.folderId))
}
const duplicateConditions = [
eq(workflow.workspaceId, workspaceId),
isNull(workflow.archivedAt),
eq(workflow.name, requestedName),
]

if (folderId) {
duplicateConditions.push(eq(workflow.folderId, folderId))
} else {
duplicateConditions.push(isNull(workflow.folderId))
}

const [duplicateWorkflow] = await db
.select({ id: workflow.id })
.from(workflow)
.where(and(...duplicateConditions))
.limit(1)
const [duplicateWorkflow] = await db
.select({ id: workflow.id })
.from(workflow)
.where(and(...duplicateConditions))
.limit(1)

if (duplicateWorkflow) {
return NextResponse.json(
{ error: `A workflow named "${name}" already exists in this folder` },
{ status: 409 }
)
if (duplicateWorkflow) {
return NextResponse.json(
{ error: `A workflow named "${requestedName}" already exists in this folder` },
{ status: 409 }
)
}
}

import('@/lib/core/telemetry')
.then(({ PlatformEvents }) => {
PlatformEvents.workflowCreated({
workflowId,
name,
workspaceId: workspaceId || undefined,
folderId: folderId || undefined,
})
})
.catch(() => {
// Silently fail
})

await db.insert(workflow).values({
id: workflowId,
userId,
Expand Down
1 change: 1 addition & 0 deletions apps/sim/app/workspace/[workspaceId]/home/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export function Home({ chatId }: HomeProps = {}) {
description,
color,
workspaceId,
deduplicate: true,
}),
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export function useImportWorkflow({ workspaceId }: UseImportWorkflowProps) {
workspaceId,
folderId,
sortOrder,
deduplicate: true,
}),
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ export function useImportWorkspace({ onSuccess }: UseImportWorkspaceProps = {})
color: workflowColor,
workspaceId: newWorkspace.id,
folderId: targetFolderId,
deduplicate: true,
}),
})

Expand Down
5 changes: 4 additions & 1 deletion apps/sim/hooks/queries/workflows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ interface CreateWorkflowVariables {
folderId?: string | null
sortOrder?: number
id?: string
deduplicate?: boolean
}

interface CreateWorkflowResult {
Expand Down Expand Up @@ -300,7 +301,8 @@ export function useCreateWorkflow() {

return useMutation({
mutationFn: async (variables: CreateWorkflowVariables): Promise<CreateWorkflowResult> => {
const { workspaceId, name, description, color, folderId, sortOrder, id } = variables
const { workspaceId, name, description, color, folderId, sortOrder, id, deduplicate } =
variables

logger.info(`Creating new workflow in workspace: ${workspaceId}`)

Expand All @@ -315,6 +317,7 @@ export function useCreateWorkflow() {
workspaceId,
folderId: folderId || null,
sortOrder,
deduplicate,
}),
})

Expand Down
Loading