{"record":{"id":"b3b74b29936e6306","repo":"RocketChat/Rocket.Chat","slug":"error-invalid-inquiry-b3b74b","errorCode":null,"errorMessage":"error-invalid-inquiry","messagePattern":"error-invalid-inquiry","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/ee/server/local-services/omnichannel.internalService.ts","lineNumber":107,"sourceCode":"\t\tif (!room.open) {\n\t\t\tthrow new Error('This_conversation_is_already_closed');\n\t\t}\n\n\t\tif (!room.onHold) {\n\t\t\tthrow new Error('error-room-not-on-hold');\n\t\t}\n\n\t\tconst { _id: roomId, servedBy } = room;\n\n\t\tif (!servedBy) {\n\t\t\tthis.logger.error({ msg: 'No serving agent found for room', roomId });\n\t\t\tthrow new Error('error-room-not-served');\n\t\t}\n\n\t\tconst inquiry = await LivechatInquiry.findOneByRoomId(roomId, {});\n\t\tif (!inquiry) {\n\t\t\tthis.logger.error({ msg: 'No inquiry found for room', roomId });\n\t\t\tthrow new Error('error-invalid-inquiry');\n\t\t}\n\n\t\tawait this.attemptToAssignRoomToServingAgentElseQueueIt({\n\t\t\troom,\n\t\t\tinquiry,\n\t\t\tservingAgent: servedBy,\n\t\t\tclientAction,\n\t\t});\n\n\t\tconst [roomResult, subsResult] = await Promise.all([\n\t\t\tLivechatRooms.unsetOnHoldByRoomId(roomId),\n\t\t\tSubscriptions.unsetOnHoldByRoomId(roomId),\n\t\t\tMessage.saveSystemMessage<IOmnichannelSystemMessage>('omnichannel_on_hold_chat_resumed', roomId, '', resumeBy, { comment }),\n\t\t]);\n\n\t\tif (roomResult.modifiedCount) {\n\t\t\tvoid notifyOnRoomChangedById(roomId);\n\t\t}","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/ee/server/local-services/omnichannel.internalService.ts#L89-L125","documentation":"Thrown by resumeRoomOnHold (omnichannel.internalService.ts:107) after the state checks pass: the service loads the room's LivechatInquiry via LivechatInquiry.findOneByRoomId(roomId) and gets null. Every livechat room must have a matching inquiry record to re-assign or queue the chat; a missing one means deleted or inconsistent data.","triggerScenarios":"Resuming an on-hold room whose inquiry record does not exist — the inquiry was deleted by another flow (contact/visitor deletion, cleanup job) or the room/inquiry pair is inconsistent (orphan room).","commonSituations":"Orphaned livechat rooms after failed migrations or manual DB surgery; inquiry removed by a concurrent operation while the room stayed on hold; environments restored from partial backups.","solutions":["Before resuming, verify the inquiry exists: LivechatInquiry.findOneByRoomId(rid) — if absent, do not attempt resume","Inspect the database for the room/inquiry pair and repair or close the orphaned room","Check server logs ('No inquiry found for room') to identify which roomId is affected and trace which flow deleted its inquiry"],"exampleFix":"// before\nawait omnichannelService.resumeRoomOnHold(room, comment, agent);\n\n// after\nconst inquiry = await LivechatInquiry.findOneByRoomId(room._id, { projection: { _id: 1 } });\nif (!inquiry) {\n\tthrow new Error('error-invalid-inquiry'); // or close the orphan room explicitly\n}\nawait omnichannelService.resumeRoomOnHold(room, comment, agent);","handlingStrategy":"validation","validationCode":"const inquiry = await LivechatInquiry.findOneByRoomId(rid, { projection: { _id: 1 } });\nif (!inquiry) {\n\t// orphan room — close it or alert; do not resume\n\tthrow new Error('error-invalid-inquiry');\n}\nawait omnichannelService.resumeRoomOnHold(room, comment, agent);","typeGuard":null,"tryCatchPattern":"try {\n\tawait omnichannelService.resumeRoomOnHold(room, comment, agent);\n} catch (e) {\n\tif (e instanceof Error && e.message === 'error-invalid-inquiry') {\n\t\t// data inconsistency: close the orphaned room instead of retrying\n\t}\n\tthrow e;\n}","preventionTips":["Verify a room/inquiry pair exists before resume flows","Avoid flows that delete LivechatInquiry records without also closing or clearing their rooms","Run consistency checks for orphaned livechat rooms after migrations or restores"],"tags":["omnichannel","livechat","inquiry","data-inconsistency","on-hold"],"backgroundTag":"resource-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"}