diff --git a/packages/insomnia/src/common/import.ts b/packages/insomnia/src/common/import.ts index 9fa4978a82d..2b68a763895 100644 --- a/packages/insomnia/src/common/import.ts +++ b/packages/insomnia/src/common/import.ts @@ -201,7 +201,14 @@ export const importResourcesToWorkspace = async ({ workspaceId }: { workspaceId: // Create new ids for each resource below optionalResources for (const resource of optionalResources) { const model = getModel(resource.type); - model && ResourceIdMap.set(resource._id, generateId(model.prefix)); + if (model) { + if (!resource._id) { + ResourceIdMap.set(resource._id, generateId(model.prefix)); + } else { + console.log('[Import Scan] Retaining ID: ', resource._id); + ResourceIdMap.set(resource._id, resource._id); + } + } } // Preserve optionalResource relationships @@ -298,7 +305,14 @@ const importResourcesToNewWorkspace = async (projectId: string, workspaceToImpor for (const resource of resourcesWithoutWorkspaceAndApiSpec) { const model = getModel(resource.type); - model && ResourceIdMap.set(resource._id, generateId(model.prefix)); + if (model) { + if (!resource._id) { + ResourceIdMap.set(resource._id, generateId(model.prefix)); + } else { + console.log('[Import Scan] Retaining ID: ', resource._id); + ResourceIdMap.set(resource._id, resource._id); + } + } } for (const resource of resourcesWithoutWorkspaceAndApiSpec) {