{"record":{"id":"7a36936e72bccf06","repo":"RocketChat/Rocket.Chat","slug":"error-invalid-user-7a3693","errorCode":"error-invalid-user","errorMessage":"Invalid user","messagePattern":"Invalid user","errorType":"exception","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/meteor-methods/import/uploadImportFile.ts","lineNumber":72,"sourceCode":"\t});\n\n\tawait instance.updateProgress(ProgressStep.FILE_LOADED);\n};\n\ndeclare module '@rocket.chat/ddp-client' {\n\t// eslint-disable-next-line @typescript-eslint/naming-convention\n\tinterface ServerMethods {\n\t\tuploadImportFile(binaryContent: string, contentType: string, fileName: string, importerKey: string): void;\n\t}\n}\n\nMeteor.methods<ServerMethods>({\n\tasync uploadImportFile(binaryContent, contentType, fileName, importerKey) {\n\t\tmethodDeprecationLogger.method('uploadImportFile', '9.0.0', '/v1/uploadImportFile');\n\t\tconst userId = Meteor.userId();\n\n\t\tif (!userId) {\n\t\t\tthrow new Meteor.Error('error-invalid-user', 'Invalid user', 'uploadImportFile');\n\t\t}\n\n\t\tif (!(await hasPermissionAsync(userId, 'run-import'))) {\n\t\t\tthrow new Meteor.Error('error-action-not-allowed', 'Importing is not allowed', 'uploadImportFile');\n\t\t}\n\n\t\tawait executeUploadImportFile(userId, binaryContent, contentType, fileName, importerKey);\n\t},\n});\n","sourceCodeStart":54,"sourceCodeEnd":82,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/meteor-methods/import/uploadImportFile.ts#L54-L82","documentation":"uploadImportFile's login gate: `Meteor.userId()` returning null triggers error-invalid-user. The method writes an uploaded file into server storage and the imports collection, so an authenticated user is mandatory.","triggerScenarios":"Calling `Meteor.call('uploadImportFile', ...)` while logged out or after the DDP session/token expired; invoking from server code without a user context.","commonSituations":"Upload widgets that skip the login check when the session silently expired; headless scripts uploading exports without first authenticating.","solutions":["Authenticate and verify `Meteor.userId()` before uploading","Re-login and retry on error-invalid-user","Use POST /v1/uploadImportFile with auth headers for automation"],"exampleFix":"// before\nMeteor.call('uploadImportFile', bin, 'text/csv', 'users.csv', 'csv', cb); // error-invalid-user\n\n// after\nif (!Meteor.userId()) { await relogin(); }\nMeteor.call('uploadImportFile', bin, 'text/csv', 'users.csv', 'csv', cb);","handlingStrategy":"validation","validationCode":"if (!Meteor.userId()) { await relogin(); }\nMeteor.call('uploadImportFile', bin, contentType, fileName, 'csv', cb);","typeGuard":null,"tryCatchPattern":"Meteor.call('uploadImportFile', bin, type, name, key, (err) => {\n  if (err && (err as Meteor.Error).error === 'error-invalid-user') {\n    // re-authenticate, then retry the upload once\n  }\n});","preventionTips":["Verify Meteor.userId() before the upload action","Re-login on session-expiry events","Use REST /v1/uploadImportFile for scripts"],"tags":["rocket-chat","authentication","import","meteor-methods"],"backgroundTag":"user-not-authenticated","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}