{"record":{"id":"dd153fc05efab0a8","repo":"RocketChat/Rocket.Chat","slug":"error-invalid-inquiry-dd153f","errorCode":"error-invalid-inquiry","errorMessage":"error-invalid-inquiry","messagePattern":"error-invalid-inquiry","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","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/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/ee/server/patches/verifyContactChannel.ts#L70-L106","documentation":"After the verify+merge transaction commits, runVerifyContactChannel looks up the Livechat inquiry by roomId to re-queue/verify it; if none exists it throws error-invalid-inquiry. The code comment states this means 'something is really wrong with the queue' — the contact merge already committed (no rollback happens) and only the queue step failed.","triggerScenarios":"An omnichannel room whose livechat_inquiry record is missing while verification runs: inquiry deleted by queue cleanup, concurrently taken/removed by an agent, or data inconsistency from manual deletion or partial restore.","commonSituations":"Race between an agent taking the room off the queue and the visitor verifying their channel; manual deletion of inquiry documents; restores with missing inquiry collections.","solutions":["Check the livechat_inquiry collection for the room (db.livechat_inquiry.findOne({ rid: roomId })) to confirm the record is missing.","Determine whether an agent took the room concurrently — the room may need manual re-queueing via omnichannel queue APIs.","If inquiries are systematically missing, audit rooms-vs-inquiries integrity before re-triggering verification.","Note the merge itself succeeded — only re-create/re-queue the inquiry rather than re-running the whole flow."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const inquiry = await LivechatInquiry.findOneByRoomId(roomId);\nif (!inquiry) {\n\t// queue record missing: fix/re-create the inquiry before triggering verification\n}","typeGuard":null,"tryCatchPattern":"try {\n\tawait runVerifyContactChannel(null, params);\n} catch (e) {\n\tif (e instanceof Error && e.message === 'error-invalid-inquiry') {\n\t\t// merge already committed: re-create/re-queue the inquiry manually and alert ops\n\t}\n\tthrow e;\n}","preventionTips":["Monitor consistency between livechat_rooms and livechat_inquiry collections","Avoid triggering verification at the same moment an agent takes the room from the queue","Remember this error means the destructive part succeeded — do not blindly re-run the flow"],"tags":["livechat","inquiry","queue","data-integrity","enterprise"],"backgroundTag":"data-integrity-violation","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"}