{"record":{"id":"08eeed4483c9abbe","repo":"RocketChat/Rocket.Chat","slug":"error-invalid-user-08eeed","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/messages/followMessage.ts","lineNumber":59,"sourceCode":"\n\tvoid notifyOnMessageChange({\n\t\tid,\n\t});\n\n\tconst isFollowed = true;\n\tawait Apps.self?.triggerEvent(AppEvents.IPostMessageFollowed, message, user, isFollowed);\n\n\treturn followResult;\n};\n\nMeteor.methods<ServerMethods>({\n\tasync followMessage({ mid }) {\n\t\tmethodDeprecationLogger.method('followMessage', '9.0.0', '/v1/chat.followMessage');\n\t\tcheck(mid, String);\n\n\t\tconst user = (await Meteor.userAsync()) as IUser;\n\t\tif (!user) {\n\t\t\tthrow new Meteor.Error('error-invalid-user', 'Invalid user', { method: 'followMessage' });\n\t\t}\n\n\t\treturn followMessage(user, { mid });\n\t},\n});\n\nRateLimiter.limitMethod('followMessage', 5, 5000, {\n\tuserId() {\n\t\treturn true;\n\t},\n});\n","sourceCodeStart":41,"sourceCodeEnd":71,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/meteor-methods/messages/followMessage.ts#L41-L71","documentation":"The followMessage Meteor-method wrapper loads the caller with Meteor.userAsync(); a null result throws 'error-invalid-user'. This happens when the connection has no valid login (or its user record cannot be loaded), independent of the follow logic itself. The method is deprecated since 9.0.0 in favor of POST /v1/chat.followMessage and is rate-limited to 5 calls per 5 seconds per user.","triggerScenarios":"Meteor.call('followMessage', { mid }) on an unauthenticated or expired DDP session.","commonSituations":"Follow toggles in UIs left open across logouts; token expiry while a thread view was mounted; integrations toggling follow over DDP without login.","solutions":["Guard with Meteor.userId() before calling; re-login if null","Migrate to POST /v1/chat.followMessage with an authenticated token (deprecation target)","On error, re-run the auth flow and retry once"],"exampleFix":"// before\nMeteor.call('followMessage', { mid });\n\n// after\nif (!Meteor.userId()) {\n  // re-authenticate first\n}\nMeteor.call('followMessage', { mid });","handlingStrategy":"validation","validationCode":"if (!Meteor.userId()) {\n  // re-authenticate before following threads\n} else {\n  Meteor.call('followMessage', { mid });\n}","typeGuard":null,"tryCatchPattern":"try {\n  await Meteor.callAsync('followMessage', { mid });\n} catch (e) {\n  if ((e as Meteor.Error).error === 'error-invalid-user') {\n    // session lost: re-login, then retry once (mind the 5/5s rate limit)\n  }\n}","preventionTips":["Check Meteor.userId() before calling; the wrapper loads the full user record","Migrate to POST /v1/chat.followMessage (deprecation target)","Respect the method rate limit (5 calls per 5000 ms) when retrying"],"tags":["meteor","ddp","authentication","threads"],"backgroundTag":"user-not-authenticated","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}