{"record":{"id":"badf743a6ce39f68","repo":"RocketChat/Rocket.Chat","slug":"error-operation-not-found-badf74","errorCode":"error-operation-not-found","errorMessage":"Import Operation Not Found","messagePattern":"Import Operation Not Found","errorType":"exception","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/meteor-methods/import/startImport.ts","lineNumber":14,"sourceCode":"import type { IUser } from '@rocket.chat/core-typings';\nimport type { ServerMethods } from '@rocket.chat/ddp-client';\nimport { Imports } from '@rocket.chat/models';\nimport { isStartImportParamsPOST, type StartImportParamsPOST } from '@rocket.chat/rest-typings';\nimport { Meteor } from 'meteor/meteor';\n\nimport { hasPermissionAsync } from '../../lib/authorization/hasPermission';\nimport { methodDeprecationLogger } from '../../lib/deprecationWarningLogger';\nimport { Importers } from '../../lib/import';\n\nexport const executeStartImport = async ({ input }: StartImportParamsPOST, startedByUserId: IUser['_id']) => {\n\tconst operation = await Imports.findLastImport();\n\tif (!operation) {\n\t\tthrow new Meteor.Error('error-operation-not-found', 'Import Operation Not Found', 'startImport');\n\t}\n\n\tconst { importerKey } = operation;\n\tconst importer = Importers.get(importerKey);\n\tif (!importer) {\n\t\tthrow new Meteor.Error('error-importer-not-defined', `The importer (${importerKey}) has no import class defined.`, 'startImport');\n\t}\n\n\tconst instance = new importer.importer(importer, operation); // eslint-disable-line new-cap\n\n\tawait instance.startImport(input, startedByUserId);\n};\n\ndeclare module '@rocket.chat/ddp-client' {\n\t// eslint-disable-next-line @typescript-eslint/naming-convention\n\tinterface ServerMethods {\n\t\tstartImport(params: StartImportParamsPOST): void;\n\t}","sourceCodeStart":1,"sourceCodeEnd":32,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/meteor-methods/import/startImport.ts#L1-L32","documentation":"executeStartImport begins with `Imports.findLastImport()` and throws error-operation-not-found when the collection has no import operation. startImport continues the most recent import (file already uploaded and prepared); it cannot create one, so calling it before upload/preparation always fails this way.","triggerScenarios":"Calling `Meteor.call('startImport', { input })` before `uploadImportFile` has created an operation, or after the operation document was deleted between preparation and start.","commonSituations":"Clients that jump straight to startImport without the upload step; racing tabs where one cleared the import; retrying startImport after the operation was superseded by a new upload.","solutions":["Run the full order: uploadImportFile → poll getImportFileData until it returns a selection → startImport with that selection","If the operation vanished, re-upload the file to create a new one","On 9.x use POST /v1/uploadImportFile and POST /v1/startImport"],"exampleFix":"// before\nMeteor.call('startImport', { input: selection }, cb); // error-operation-not-found\n\n// after — ensure an operation exists first\nMeteor.call('getImportFileData', (e, data) => {\n  if (e) { /* start with uploadImportFile */ return; }\n  Meteor.call('startImport', { input: buildInput(data) });\n});","handlingStrategy":"validation","validationCode":"// Only call startImport once a prepared selection exists\nMeteor.call('getImportFileData', (e, data) => {\n  if (e) { /* upload first */ return; }\n  if (data && !('waiting' in data)) Meteor.call('startImport', { input: toShortSelection(data) });\n});","typeGuard":"const hasSelection = (d: IImporterSelection | { waiting: true } | undefined): d is IImporterSelection =>\n  !!d && !('waiting' in d);","tryCatchPattern":"try {\n  await meteorCall('startImport', { input });\n} catch (e) {\n  if (e instanceof Meteor.Error && e.error === 'error-operation-not-found') {\n    // import vanished: restart from uploadImportFile\n  }\n}","preventionTips":["Drive the import wizard as a state machine: upload → prepare → selection → start","Never call startImport without a successful getImportFileData first","Re-upload rather than retrying when the operation is gone"],"tags":["rocket-chat","import","not-found","meteor-methods"],"backgroundTag":"import-operation-not-found","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}