{"record":{"id":"0b710b57ecd06272","repo":"RocketChat/Rocket.Chat","slug":"error-invalid-room-0b710b","errorCode":"error-invalid-room","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/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/ee/server/patches/verifyContactChannel.ts#L55-L91","documentation":"Thrown by runVerifyContactChannel (EE contact-channel verification) when LivechatRooms.findOneById(roomId) returns null: the room whose channel is being verified does not exist. The room is needed both for the verification transaction and for the subsequent inquiry/queue handling.","triggerScenarios":"Triggering the verify contact channel flow with a roomId that was deleted or never existed — e.g. the room was closed/deleted between the client loading it and submitting verification, or a typo'd/stale id is passed by an integration.","commonSituations":"Omnichannel room deleted by cleanup jobs or an agent while the visitor was verifying, stale client session after room deletion, programmatic callers passing an unvalidated id.","solutions":["Confirm the room still exists before triggering verification (LivechatRooms.findOneById or the room info REST endpoint).","Refresh the client's room reference — the room may be gone; restart the conversation/room as needed.","For API integrations, validate roomId format and existence before invoking the flow."],"exampleFix":"// before\nawait runVerifyContactChannel(null, { contactId, field, value, visitorId, roomId });\n\n// after\nconst room = await LivechatRooms.findOneById(roomId);\nif (!room) throw new Meteor.Error('error-invalid-room', `Room ${roomId} not found`);\nawait runVerifyContactChannel(null, { contactId, field, value, visitorId, roomId });","handlingStrategy":"validation","validationCode":"const room = await LivechatRooms.findOneById(roomId, { projection: { _id: 1 } });\nif (!room) {\n\t// room deleted or wrong id: do not trigger verification\n}","typeGuard":"const isValidRoomId = async (roomId: string): Promise<boolean> =>\n\t!!(await LivechatRooms.findOneById(roomId, { projection: { _id: 1 } }));","tryCatchPattern":"try {\n\tawait runVerifyContactChannel(null, params);\n} catch (e) {\n\tif (e instanceof Error && e.message === 'error-invalid-room') {\n\t\t// reload room list / tell the user the room is gone; no retry will help\n\t}\n\tthrow e;\n}","preventionTips":["Re-validate room existence before long-running user flows that end in verification","Pass server-resolved room ids, never raw user input, to verification flows"],"tags":["livechat","rooms","validation","enterprise"],"backgroundTag":"entity-not-found","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","contentChangedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}