{"record":{"id":"efcd9e9fb2f5ce67","repo":"RocketChat/Rocket.Chat","slug":"error-invalid-user-efcd9e","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/startImport.ts","lineNumber":45,"sourceCode":"\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}\n}\n\nMeteor.methods<ServerMethods>({\n\tasync startImport({ input }: StartImportParamsPOST) {\n\t\tmethodDeprecationLogger.method('startImport', '9.0.0', '/v1/startImport');\n\t\tif (!input || typeof input !== 'object' || !isStartImportParamsPOST({ input })) {\n\t\t\tthrow new Meteor.Error(`Invalid Selection data provided to the importer.`);\n\t\t}\n\n\t\tconst userId = Meteor.userId();\n\t\t// Takes name and object with users / channels selected to import\n\t\tif (!userId) {\n\t\t\tthrow new Meteor.Error('error-invalid-user', 'Invalid user', 'startImport');\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', 'startImport');\n\t\t}\n\n\t\treturn executeStartImport({ input }, userId);\n\t},\n});\n","sourceCodeStart":27,"sourceCodeEnd":55,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/meteor-methods/import/startImport.ts#L27-L55","documentation":"startImport's authentication gate: after payload validation it reads `Meteor.userId()` and throws error-invalid-user when null. The method mutates workspace data, so an anonymous or expired session is rejected before the permission check.","triggerScenarios":"Invoking `Meteor.call('startImport', { input })` from a connection whose login token expired or that never authenticated; server-side invocation without a bound user.","commonSituations":"Users leaving the import wizard open past session expiry before clicking Start; automation calling the method without login; session cleared between preparation and start steps.","solutions":["Confirm `Meteor.userId()` immediately before startImport and re-login if null","Handle error-invalid-user by re-authenticating and retrying once","Use POST /v1/startImport with user credentials for programmatic flows"],"exampleFix":"// before\nMeteor.call('startImport', { input }, cb); // error-invalid-user\n\n// after\nif (!Meteor.userId()) { await relogin(); }\nMeteor.call('startImport', { input }, cb);","handlingStrategy":"validation","validationCode":"if (!Meteor.userId()) { await relogin(); }\nMeteor.call('startImport', { input }, cb);","typeGuard":null,"tryCatchPattern":"Meteor.call('startImport', { input }, (err) => {\n  if (err && (err as Meteor.Error).error === 'error-invalid-user') {\n    // re-login and retry once\n  }\n});","preventionTips":["Re-check the session right before the Start Import action","Refresh sessions on wizard screens that may sit idle","Use REST /v1/startImport for automation"],"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"}