{"record":{"id":"bfb2910b617218b6","repo":"RocketChat/Rocket.Chat","slug":"error-invalid-user-bfb291","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/getImportProgress.ts","lineNumber":39,"sourceCode":"\n\tconst instance = new importer.importer(importer, operation); // eslint-disable-line new-cap\n\n\treturn instance.getProgress();\n};\n\ndeclare module '@rocket.chat/ddp-client' {\n\t// eslint-disable-next-line @typescript-eslint/naming-convention\n\tinterface ServerMethods {\n\t\tgetImportProgress(): IImportProgress;\n\t}\n}\n\nMeteor.methods<ServerMethods>({\n\tasync getImportProgress() {\n\t\tmethodDeprecationLogger.method('getImportProgress', '9.0.0', '/v1/getImportProgress');\n\t\tconst userId = Meteor.userId();\n\t\tif (!userId) {\n\t\t\tthrow new Meteor.Error('error-invalid-user', 'Invalid user', 'getImportProgress');\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', 'setupImporter');\n\t\t}\n\n\t\treturn executeGetImportProgress();\n\t},\n});\n","sourceCodeStart":21,"sourceCodeEnd":49,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/meteor-methods/import/getImportProgress.ts#L21-L49","documentation":"getImportProgress requires a logged-in DDP user; when `Meteor.userId()` is null it throws error-invalid-user. It is the authentication gate before the run-import permission check, identical in shape to the guard in getImportFileData.","triggerScenarios":"Polling `Meteor.call('getImportProgress')` from a connection whose session expired or that never logged in; calling the method from a background job without user context.","commonSituations":"Progress-polling loops that outlive the login session (long imports); scripts hitting DDP directly; front-end code that starts polling after logout.","solutions":["Ensure an authenticated session before polling (`Meteor.userId()` is set)","Re-authenticate on this error and resume polling","Move automation to POST /v1/getImportProgress with X-User-Id/X-Auth-Token headers"],"exampleFix":"// before\nsetInterval(() => Meteor.call('getImportProgress', cb), 2000); // error-invalid-user after logout\n\n// after\nsetInterval(() => {\n  if (!Meteor.userId()) { stopPolling(); return; }\n  Meteor.call('getImportProgress', cb);\n}, 2000);","handlingStrategy":"validation","validationCode":"if (!Meteor.userId()) { await relogin(); }\nMeteor.call('getImportProgress', cb);","typeGuard":null,"tryCatchPattern":"Meteor.call('getImportProgress', (err, p) => {\n  if (err && (err as Meteor.Error).error === 'error-invalid-user') {\n    stopPolling(); // then re-login and restart the poll\n  }\n});","preventionTips":["Stop progress polling on logout/session-expiry events","Re-authenticate before long import sessions","Use REST /v1/getImportProgress for headless monitoring"],"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"}