{"record":{"id":"21fb032b9987c0ed","repo":"RocketChat/Rocket.Chat","slug":"error-invalid-user-21fb03","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/getLatestImportOperations.ts","lineNumber":34,"sourceCode":"\t);\n\n\treturn data.toArray();\n};\n\ndeclare module '@rocket.chat/ddp-client' {\n\t// eslint-disable-next-line @typescript-eslint/naming-convention\n\tinterface ServerMethods {\n\t\tgetLatestImportOperations(): IImport[];\n\t}\n}\n\nMeteor.methods<ServerMethods>({\n\tasync getLatestImportOperations() {\n\t\tmethodDeprecationLogger.method('getLatestImportOperations', '9.0.0', '/v1/getLatestImportOperations');\n\t\tconst userId = Meteor.userId();\n\n\t\tif (!userId) {\n\t\t\tthrow new Meteor.Error('error-invalid-user', 'Invalid user', 'getLatestImportOperations');\n\t\t}\n\n\t\tif (!(await hasPermissionAsync(userId, 'view-import-operations'))) {\n\t\t\tthrow new Meteor.Error('not_authorized', 'User not authorized', 'getLatestImportOperations');\n\t\t}\n\n\t\treturn executeGetLatestImportOperations();\n\t},\n});\n","sourceCodeStart":16,"sourceCodeEnd":44,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/meteor-methods/import/getLatestImportOperations.ts#L16-L44","documentation":"getLatestImportOperations lists past imports; it first requires a logged-in user and throws error-invalid-user when `Meteor.userId()` is null. Without an authenticated session the operation history is never disclosed.","triggerScenarios":"Calling `Meteor.call('getLatestImportOperations')` from an anonymous DDP connection, an expired session, or server code without a user bound to the invocation.","commonSituations":"Admin dashboards loaded after session timeout; scripts querying import history without login; preflight checks run before authentication completes.","solutions":["Log in and verify `Meteor.userId()` before calling","Re-authenticate and retry once when this error appears","Use GET/POST /v1/getLatestImportOperations with auth headers for programmatic access"],"exampleFix":"// before\nMeteor.call('getLatestImportOperations', cb); // error-invalid-user\n\n// after\nif (!Meteor.userId()) await relogin();\nMeteor.call('getLatestImportOperations', cb);","handlingStrategy":"validation","validationCode":"if (!Meteor.userId()) { await relogin(); }\nMeteor.call('getLatestImportOperations', cb);","typeGuard":null,"tryCatchPattern":"Meteor.call('getLatestImportOperations', (err, ops) => {\n  if (err && (err as Meteor.Error).error === 'error-invalid-user') {\n    // re-authenticate, then retry once\n  }\n});","preventionTips":["Authenticate dashboards before loading import history","Handle token expiry uniformly for all admin-area calls","Use REST /v1/getLatestImportOperations 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"}