{"record":{"id":"bbcd6b746dc1aee4","repo":"RocketChat/Rocket.Chat","slug":"invalid-room-bbcd6b","errorCode":"invalid-room","errorMessage":"invalid-room","messagePattern":"invalid-room","errorType":"error_code","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/lib/omnichannel/getRoomMessages.ts","lineNumber":8,"sourceCode":"import type { MessageTypesValues, IRoom } from '@rocket.chat/core-typings';\nimport { Rooms, Messages } from '@rocket.chat/models';\nimport { Meteor } from 'meteor/meteor';\n\nexport async function getRoomMessages({ rid }: { rid: string }) {\n\tconst room = await Rooms.findOneById<Pick<IRoom, 't'>>(rid, { projection: { t: 1 } });\n\tif (room?.t !== 'l') {\n\t\tthrow new Meteor.Error('invalid-room');\n\t}\n\n\tconst ignoredMessageTypes: MessageTypesValues[] = [\n\t\t'livechat_navigation_history',\n\t\t'livechat_transcript_history',\n\t\t'command',\n\t\t'livechat-close',\n\t\t'livechat-started',\n\t\t'livechat_video_call',\n\t];\n\n\treturn Messages.findVisibleByRoomIdNotContainingTypes(rid, ignoredMessageTypes, {\n\t\tsort: { ts: 1 },\n\t});\n}\n","sourceCodeStart":1,"sourceCodeEnd":24,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/lib/omnichannel/getRoomMessages.ts#L1-L24","documentation":"Thrown by `getRoomMessages({ rid })` when the room cannot be found OR its `t` (type) is not `'l'` (livechat). Only omnichannel rooms are valid here: the query projects `{ t: 1 }` and any channel/private-group/direct room fails the `room?.t !== 'l'` check just as hard as a missing room.","triggerScenarios":"Calling the transcript/message-history flow backed by this helper with a regular channel rid, a typo'd rid, or a room deleted between the client loading it and requesting its transcript.","commonSituations":"Widget or API code reusing a generic room id for a livechat-only endpoint; rooms removed by retention policies; confusion between channel names and livechat room ids.","solutions":["Ensure the rid passed belongs to a livechat room (created via the omnichannel/inquiry flow)","Validate with a `Rooms.findOneById(rid, { projection: { t: 1 } })` style check before calling","If the room was deleted, surface 'conversation no longer exists' instead of retrying"],"exampleFix":"// before\nawait getRoomMessages({ rid: generalChannelId });\n\n// after\nconst room = await Rooms.findOneById<Pick<IRoom, 't'>>(rid, { projection: { t: 1 } });\nif (room?.t !== 'l') throw new Error('Transcripts are only available for livechat rooms');\nawait getRoomMessages({ rid });","handlingStrategy":"type-guard","validationCode":"const room = await Rooms.findOneById<Pick<IRoom, 't'>>(rid, { projection: { t: 1 } });\nif (room?.t !== 'l') throw new Error('Not a livechat room');\nawait getRoomMessages({ rid });","typeGuard":"const isLivechatRoom = (room: Pick<IRoom, 't'> | null): room is Pick<IRoom, 't'> & { t: 'l' } =>\n  room?.t === 'l';","tryCatchPattern":"try {\n  await getRoomMessages({ rid });\n} catch (e) {\n  if (isMeteorError(e, 'invalid-room')) {\n    // show 'conversation unavailable' — do not retry\n  }\n}","preventionTips":["Only feed room ids originating from the omnichannel inquiry/room flow to livechat-only helpers","Type-narrow rooms by t === 'l' before livechat-specific calls","Handle deleted-room races with a terminal error state"],"tags":["omnichannel","rooms","livechat","invalid-room-type","transcript"],"backgroundTag":"invalid-room-type","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}