{"record":{"id":"dd153fc05efab0a8","repo":"RocketChat/Rocket.Chat","slug":"error-invalid-inquiry-dd153f","errorCode":null,"errorMessage":"error-invalid-inquiry","messagePattern":"error-invalid-inquiry","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"apps/meteor/ee/server/patches/verifyContactChannel.ts","lineNumber":88,"sourceCode":"\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) {\n\t\tlogger.debug({ msg: 'Verifying inquiry', roomId });\n\t\tawait QueueManager.verifyInquiry(inquiry, room);\n\t}\n\n\tlogger.debug({\n\t\tmsg: 'Contact channel has been verified and merged successfully',\n\t\tcontactId,\n\t\tvisitorId,\n\t\troomId,\n\t});\n\n\treturn result;\n};\n\nverifyContactChannel.patch(runVerifyContactChannel, () => License.hasModule('contact-id-verification'));","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/f9d3ec372bb580fa8d036f94cf03925a478ef768/apps/meteor/ee/server/patches/verifyContactChannel.ts#L70-L106","documentation":"Thrown by runVerifyContactChannel after the contact merge transaction succeeds but LivechatInquiry.findOneByRoomId(roomId) returns null. The comment in code marks this as 'something is really wrong with the queue' — an inquiry is expected to exist for any omnichannel room in this flow. Throwing prevents carrying on a half-verified state where the contact was merged but no inquiry exists to re-queue.","triggerScenarios":"The room exists, the contact/channel merge committed, but the associated livechat inquiry document is missing — typically because it was removed, the room was never properly queued, or another worker already took and closed it.","commonSituations":"Queue corruption from a partial migration, manual DB deletion of inquiries, a previously failed take-inquiry that left no inquiry behind, or a room created outside the normal omnichannel queueing path.","solutions":["Investigate why the inquiry is missing (audit logs, manual db deletion, failed migration).","Re-create or restore the inquiry for the room so the queue is consistent.","If the room is stale/closed, mark the verification as moot instead of continuing.","Add a reconciliation job that repairs rooms whose inquiry is absent."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"async function inquiryExistsForRoom(roomId: string): Promise<boolean> {\n  const inq = await LivechatInquiry.findOneByRoomId(roomId, { projection: { _id: 1 } });\n  return Boolean(inq);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await verifyContactChannel(params);\n} catch (e) {\n  if (e.message === 'error-invalid-inquiry') {\n    // page an admin / run a queue reconciliation job\n  } else throw e;\n}","preventionTips":["Run a periodic reconciliation job that repairs rooms without inquiries.","Audit manual db deletions of inquiry documents.","Alert operations when this fires — it signals queue corruption.","Validate inquiry presence after any migration touching livechat_inquiry."],"tags":["omnichannel","inquiry","queue","data-integrity","contacts"],"backgroundTag":null,"analyzedSha":"f9d3ec372bb580fa8d036f94cf03925a478ef768","analyzedAt":"2026-08-12T19:07:17.372Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}