File tree Expand file tree Collapse file tree
apps/sim/app/workspace/[workspaceId]/w/hooks Expand file tree Collapse file tree Original file line number Diff line number Diff 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 ( / \. z i p $ / i, '' )
97107 const importFolder = await createFolder ( {
You can’t perform that action at this time.
0 commit comments