Skip to content

Commit f7b45a8

Browse files
fix(workflows): return 4xx errors from duplicate route
1 parent 5332614 commit f7b45a8

File tree

1 file changed

+17
-0
lines changed
  • apps/sim/app/api/workflows/[id]/duplicate

1 file changed

+17
-0
lines changed

apps/sim/app/api/workflows/[id]/duplicate/route.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,23 @@ export async function POST(req: NextRequest, { params }: { params: Promise<{ id:
9393
)
9494
return NextResponse.json({ error: 'Access denied' }, { status: 403 })
9595
}
96+
97+
if (error.message === 'Write or admin access required for target workspace') {
98+
logger.warn(
99+
`[${requestId}] User ${userId} lacks write access to target workspace`
100+
)
101+
return NextResponse.json({ error: 'Write or admin access required' }, { status: 403 })
102+
}
103+
104+
if (error.message.includes('not attached to a workspace')) {
105+
logger.warn(`[${requestId}] Workflow not attached to a workspace`)
106+
return NextResponse.json({ error: error.message }, { status: 400 })
107+
}
108+
109+
if (error.message === 'Workspace ID is required') {
110+
logger.warn(`[${requestId}] Missing workspace ID in duplication request`)
111+
return NextResponse.json({ error: 'Workspace ID is required' }, { status: 400 })
112+
}
96113
}
97114

98115
if (error instanceof z.ZodError) {

0 commit comments

Comments
 (0)