Skip to content

Commit 455d3e2

Browse files
committed
fix(workflows): clarify invalid import file errors
1 parent e987490 commit 455d3e2

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

apps/sim/app/workspace/[workspaceId]/w/hooks/use-import-workflow.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,11 @@ export function useImportWorkflow({ workspaceId }: UseImportWorkflowProps) {
6868
}),
6969
})
7070

71-
return result?.workflowId ?? null
71+
if (!result) {
72+
throw new Error('The file does not contain valid workflow JSON.')
73+
}
74+
75+
return result.workflowId
7276
},
7377
[clearDiff, createWorkflow, workspaceId]
7478
)
@@ -91,7 +95,13 @@ export function useImportWorkflow({ workspaceId }: UseImportWorkflowProps) {
9195

9296
if (hasZip && fileArray.length === 1) {
9397
const zipFile = fileArray[0]
94-
const { workflows: extractedWorkflows, metadata } = await extractWorkflowsFromZip(zipFile)
98+
const { workflows: extractedWorkflows, metadata } = await extractWorkflowsFromZip(
99+
zipFile
100+
).catch((error: unknown) => {
101+
throw new Error('Failed to import ZIP file. Check that it is a valid ZIP archive.', {
102+
cause: error,
103+
})
104+
})
95105

96106
const folderName = metadata?.workspaceName || zipFile.name.replace(/\.zip$/i, '')
97107
const importFolder = await createFolder({

0 commit comments

Comments
 (0)