{"record":{"id":"550f11d06387a225","repo":"RocketChat/Rocket.Chat","slug":"error-invalid-room-550f11","errorCode":"error-invalid-room","errorMessage":"Invalid room","messagePattern":"Invalid room","errorType":"exception","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/publications/messages.ts","lineNumber":300,"sourceCode":"\n\treturn handleCursorPagination(type, rid, count, next, previous);\n};\n\nMeteor.methods<ServerMethods>({\n\tasync 'messages/get'(\n\t\trid,\n\t\t{ lastUpdate, latestDate = new Date(), oldestDate, inclusive = false, count = 20, unreads = false, next, previous, type },\n\t) {\n\t\tcheck(rid, String);\n\n\t\tconst fromId = Meteor.userId();\n\n\t\tif (!fromId) {\n\t\t\tthrow new Meteor.Error('error-invalid-user', 'Invalid user', { method: 'messages/get' });\n\t\t}\n\n\t\tif (!rid) {\n\t\t\tthrow new Meteor.Error('error-invalid-room', 'Invalid room', { method: 'messages/get' });\n\t\t}\n\n\t\treturn getMessageHistory(rid, fromId, { lastUpdate, latestDate, oldestDate, inclusive, count, unreads, next, previous, type });\n\t},\n});\n","sourceCodeStart":282,"sourceCodeEnd":306,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/publications/messages.ts#L282-L306","documentation":"Thrown by the 'messages/get' Meteor method when rid is falsy after the check(rid, String) match — in practice an empty string. The room id is the primary key for the history query, so an empty value cannot resolve to a room. Non-string values are rejected earlier by check() with a Match failed error instead.","triggerScenarios":"Meteor.call('messages/get', '', { ... }); calling with a rid variable that is undefined-but-defaulted to '' or comes from an unset route param.","commonSituations":"Route handlers that read :rid from a URL before the subscription populates; deserialized state where the room id was never stored; passing a room name instead of the _id.","solutions":["Pass the room's _id (not its name) and verify it is non-empty before calling","Derive rid from the user's subscription records when it is unknown","Guard the call site: if (!rid) return"],"exampleFix":"// before\nMeteor.call('messages/get', rid ?? '', { lastUpdate });\n\n// after\nif (!rid) throw new Error('rid is required');\nMeteor.call('messages/get', rid, { lastUpdate });","handlingStrategy":"validation","validationCode":"if (typeof rid !== 'string' || rid.trim() === '') {\n  throw new Error('a non-empty room id is required');\n}\nMeteor.call('messages/get', rid, params);","typeGuard":"function isValidRoomId(rid: unknown): rid is string {\n  return typeof rid === 'string' && rid.length > 0;\n}","tryCatchPattern":"try { await Meteor.callAsync('messages/get', rid, params); } catch (e) { if (e.error === 'error-invalid-room') { /* resolve rid from subscriptions and retry */ } }","preventionTips":["Pass room _id, never the room name","Derive rid from the subscription record when it is unknown"],"tags":["meteor","messages-get","validation","rocket-chat"],"backgroundTag":"invalid-room-id","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-08-21T10:36:37.832Z"}