{"record":{"id":"e84eadb9afabf6ff","repo":"RocketChat/Rocket.Chat","slug":"error-invalid-user-e84ead","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/getSingleMessage.ts","lineNumber":37,"sourceCode":"\tif (!msg?.rid) {\n\t\treturn null;\n\t}\n\n\tif (!(await canAccessRoomIdAsync(msg.rid, userId))) {\n\t\tthrow new Meteor.Error('error-not-allowed', 'Not allowed', { method: 'getSingleMessage' });\n\t}\n\n\treturn msg;\n};\n\nMeteor.methods<ServerMethods>({\n\tasync getSingleMessage(mid) {\n\t\tcheck(mid, String);\n\n\t\tconst uid = Meteor.userId();\n\n\t\tif (!uid) {\n\t\t\tthrow new Meteor.Error('error-invalid-user', 'Invalid user', { method: 'getSingleMessage' });\n\t\t}\n\n\t\treturn getSingleMessage(uid, mid);\n\t},\n});\n","sourceCodeStart":19,"sourceCodeEnd":43,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/meteor-methods/messages/getSingleMessage.ts#L19-L43","documentation":"The getSingleMessage Meteor-method wrapper throws 'error-invalid-user' when Meteor.userId() is null — no authenticated user on the DDP connection. The room-access check inside the helper never runs because the user id itself is missing.","triggerScenarios":"Meteor.call('getSingleMessage', mid) from an anonymous connection or one whose token expired/was revoked.","commonSituations":"Deep-link handling in tabs that lost their session; integrations fetching single messages over DDP without login.","solutions":["Guard on Meteor.userId(); re-login when null","Use GET /v1/chat.getMessage with an authenticated token instead","Retry once after re-authentication for deep-link flows"],"exampleFix":"// before\nMeteor.call('getSingleMessage', mid);\n\n// after\nif (!Meteor.userId()) {\n  // re-authenticate, then retry\n}\nMeteor.call('getSingleMessage', mid);","handlingStrategy":"validation","validationCode":"if (!Meteor.userId()) {\n  // re-authenticate before resolving deep-linked messages\n} else {\n  Meteor.call('getSingleMessage', mid);\n}","typeGuard":null,"tryCatchPattern":"try {\n  const msg = await Meteor.callAsync('getSingleMessage', mid);\n} catch (e) {\n  if ((e as Meteor.Error).error === 'error-invalid-user') {\n    // re-login then retry once; otherwise show unavailable\n  }\n}","preventionTips":["Guard deep-link flows with a session check before fetching","Use GET /v1/chat.getMessage with an auth token for integration flows","Match on the error code, not the 'Invalid user' message text"],"tags":["meteor","ddp","authentication","messages"],"backgroundTag":"user-not-authenticated","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}