{"record":{"id":"476a95f9edc5a654","repo":"RocketChat/Rocket.Chat","slug":"error-invalid-user-476a95","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/getImportFileData.ts","lineNumber":79,"sourceCode":"\t}\n\n\treturn instance.buildSelection();\n};\n\ndeclare module '@rocket.chat/ddp-client' {\n\t// eslint-disable-next-line @typescript-eslint/naming-convention\n\tinterface ServerMethods {\n\t\tgetImportFileData(): IImporterSelection | { waiting: true };\n\t}\n}\n\nMeteor.methods<ServerMethods>({\n\tasync getImportFileData() {\n\t\tmethodDeprecationLogger.method('getImportFileData', '9.0.0', '/v1/getImportFileData');\n\t\tconst userId = Meteor.userId();\n\n\t\tif (!userId) {\n\t\t\tthrow new Meteor.Error('error-invalid-user', 'Invalid user', 'getImportFileData');\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', 'getImportFileData');\n\t\t}\n\n\t\treturn executeGetImportFileData();\n\t},\n});\n","sourceCodeStart":61,"sourceCodeEnd":89,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/meteor-methods/import/getImportFileData.ts#L61-L89","documentation":"getImportFileData requires an authenticated DDP session; it calls `Meteor.userId()` and throws error-invalid-user when that returns null. This is the standard Rocket.Chat signal that the method was invoked without a logged-in user (no resume token, expired token, or a server-to-server call with no user context).","triggerScenarios":"Invoking `Meteor.call('getImportFileData')` from an unauthenticated DDP connection, after the accounts resume token expired, or from server-side code without a user bound to the method invocation.","commonSituations":"Long-lived admin tabs whose login token expired; automated scripts calling Meteor methods directly without logging in first; switching to 9.x where the REST equivalents (POST /v1/getImportFileData) are preferred and the method call lost its session.","solutions":["Log in before calling (Meteor.loginWithPassword / loginWithToken) and confirm `Meteor.userId()` is set","Handle token expiry: on this error, re-authenticate and retry the call once","For automation, use the REST endpoint POST /v1/getImportFileData with valid X-Auth-Token/X-User-Id headers instead of a raw DDP method call"],"exampleFix":"// before\nMeteor.call('getImportFileData', cb); // error-invalid-user when logged out\n\n// after\nif (!Meteor.userId()) {\n  await new Promise((resolve, reject) => Meteor.loginWithToken(token, (e) => (e ? reject(e) : resolve())));\n}\nMeteor.call('getImportFileData', cb);","handlingStrategy":"validation","validationCode":"if (!Meteor.userId()) {\n  // login or restore the session before calling\n  await new Promise((res, rej) => Meteor.loginWithToken(savedToken, (e) => (e ? rej(e) : res())));\n}\nMeteor.call('getImportFileData', cb);","typeGuard":null,"tryCatchPattern":"Meteor.call('getImportFileData', (err, data) => {\n  if (err && (err as Meteor.Error).error === 'error-invalid-user') {\n    // session expired: re-login, then retry once\n  }\n});","preventionTips":["Check Meteor.userId() before any import method call","Refresh long-lived sessions before entering the import wizard","Prefer REST endpoints with X-User-Id/X-Auth-Token for automation"],"tags":["rocket-chat","authentication","meteor-methods","import"],"backgroundTag":"user-not-authenticated","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}