{"record":{"id":"d3bf6bdba09e8865","repo":"RocketChat/Rocket.Chat","slug":"error-import-file-missing","errorCode":"error-import-file-missing","errorMessage":"fileUrl","messagePattern":"fileUrl","errorType":"exception","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/meteor-methods/import/downloadPublicImportFile.ts","lineNumber":51,"sourceCode":"\nfunction copyLocalFile(filePath: fs.PathLike, writeStream: fs.WriteStream): void {\n\tconst readStream = fs.createReadStream(filePath);\n\treadStream.pipe(writeStream);\n}\n\nexport const executeDownloadPublicImportFile = async (userId: IUser['_id'], fileUrl: string, importerKey: string): Promise<void> => {\n\tconst importer = Importers.get(importerKey);\n\tconst isUrl = fileUrl.startsWith('http');\n\tif (!importer) {\n\t\tthrow new Meteor.Error(\n\t\t\t'error-importer-not-defined',\n\t\t\t`The importer (${importerKey}) has no import class defined.`,\n\t\t\t'downloadImportFile',\n\t\t);\n\t}\n\t// Check if it's a valid url or path before creating a new import record\n\tif (!isUrl && !fs.existsSync(fileUrl)) {\n\t\tthrow new Meteor.Error('error-import-file-missing', fileUrl, 'downloadPublicImportFile');\n\t}\n\n\tconst operation = await Import.newOperation(userId, importer.name, importer.key);\n\tconst instance = new importer.importer(importer, operation); // eslint-disable-line new-cap\n\n\tconst oldFileName = fileUrl.substring(fileUrl.lastIndexOf('/') + 1).split('?')[0];\n\tconst date = new Date();\n\tconst dateStr = `${date.getUTCFullYear()}${date.getUTCMonth()}${date.getUTCDate()}${date.getUTCHours()}${date.getUTCMinutes()}${date.getUTCSeconds()}`;\n\tconst newFileName = `${dateStr}_${userId}_${oldFileName}`;\n\n\t// Store the file name on the imports collection\n\tawait instance.startFileUpload(newFileName);\n\tawait instance.updateProgress(ProgressStep.DOWNLOADING_FILE);\n\n\tconst writeStream = RocketChatImportFileInstance.createWriteStream(newFileName);\n\tlet errorProgressUpdate: Promise<unknown> | undefined;\n\tconst markImportAsFailed = (): Promise<unknown> => {\n\t\terrorProgressUpdate ??= instance.updateProgress(ProgressStep.ERROR).catch((error) => {","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/meteor-methods/import/downloadPublicImportFile.ts#L33-L69","documentation":"Error \"fileUrl\" thrown in RocketChat/Rocket.Chat.","triggerScenarios":"Thrown at apps/meteor/server/meteor-methods/import/downloadPublicImportFile.ts:51 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Provide a fileUrl that is either an http(s) URL or an existing local file path; the given value was neither a URL nor a path present on disk (fs.existsSync failed).","Verify the file was uploaded to the server and the path is correct."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","contentChangedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}