{"record":{"id":"0b710b57ecd06272","repo":"RocketChat/Rocket.Chat","slug":"error-invalid-room-0b710b","errorCode":null,"errorMessage":"error-invalid-room","messagePattern":"error-invalid-room","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/ee/server/patches/verifyContactChannel.ts","lineNumber":73,"sourceCode":"\t\tawait session.endSession();\n\t}\n}\n\nexport const runVerifyContactChannel = async (\n\t_next: any,\n\tparams: {\n\t\tcontactId: string;\n\t\tfield: string;\n\t\tvalue: string;\n\t\tvisitorId: string;\n\t\troomId: string;\n\t},\n): Promise<ILivechatContact | null> => {\n\tconst { roomId, contactId, visitorId } = params;\n\n\tconst room = await LivechatRooms.findOneById(roomId);\n\tif (!room) {\n\t\tthrow new Error('error-invalid-room');\n\t}\n\n\tconst result = await _verifyContactChannel(params, room);\n\n\tlogger.debug({ msg: 'Finding inquiry', roomId });\n\n\t// Note: we are not using the session here since allowing the transactional flow to be used inside the\n\t//       saveQueueInquiry function would require a lot of changes across the codebase, so if we fail here we\n\t//       will not be able to rollback the transaction. That is not a big deal since the contact will be properly\n\t//       merged and the inquiry will be saved in the queue (will need to be taken manually by an agent though).\n\tconst inquiry = await LivechatInquiry.findOneByRoomId(roomId);\n\tif (!inquiry) {\n\t\t// Note: if this happens, something is really wrong with the queue, so we should throw an error to avoid\n\t\t//       carrying on a weird state.\n\t\tthrow new Error('error-invalid-inquiry');\n\t}\n\n\tif (inquiry.status === LivechatInquiryStatus.VERIFYING) {","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/f9d3ec372bb580fa8d036f94cf03925a478ef768/apps/meteor/ee/server/patches/verifyContactChannel.ts#L55-L91","documentation":"Thrown by runVerifyContactChannel when LivechatRooms.findOneById(roomId) returns null. The room is required both as the source for the channel match and as the IOmnichannelRoom passed into _verifyContactChannel, so a missing room aborts before any transactional work starts.","triggerScenarios":"Calling verifyContactChannel with a roomId that does not correspond to any livechat room document; room was deleted between the queue step and verification; roomId mistyped or from another workspace.","commonSituations":"Stale roomId in a queued inquiry after the room was closed/deleted; race between room closure and the verification callback; cross-environment id leakage; test calling verifyContactChannel without seeding the room.","solutions":["Confirm the room exists with LivechatRooms.findOneById(roomId) before invoking verifyContactChannel.","If the room was deleted, drop the verification request and notify the agent.","Make sure the roomId is the omnichannel room _id (not the inquiry id or visitor id).","Re-check you are querying the same Mongo database/workspace."],"exampleFix":"// before\nawait verifyContactChannel({ contactId, field, value, visitorId, roomId });\n\n// after\nconst room = await LivechatRooms.findOneById(roomId);\nif (!room) throw new Error('Room not found — cannot verify channel');\nawait verifyContactChannel({ contactId, field, value, visitorId, roomId });","handlingStrategy":"validation","validationCode":"async function roomExists(roomId: string): Promise<boolean> {\n  const room = await LivechatRooms.findOneById(roomId, { projection: { _id: 1 } });\n  return Boolean(room);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await verifyContactChannel(params);\n} catch (e) {\n  if (e.message === 'error-invalid-room') {\n    // drop the verification request and notify the agent\n  } else throw e;\n}","preventionTips":["Confirm the roomId is the omnichannel room _id before invoking verify.","Re-check room existence for stale queued items before processing.","Audit cross-environment id leakage in tests."],"tags":["omnichannel","room","not-found","contacts"],"backgroundTag":null,"analyzedSha":"f9d3ec372bb580fa8d036f94cf03925a478ef768","analyzedAt":"2026-08-12T19:07:17.372Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}