{"record":{"id":"c1cfe6182fd56fa3","repo":"RocketChat/Rocket.Chat","slug":"error-returning-inquiry","errorCode":"error-returning-inquiry","errorMessage":"error-returning-inquiry","messagePattern":"error-returning-inquiry","errorType":"exception","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/lib/omnichannel/rooms.ts","lineNumber":262,"sourceCode":"\tif (!inquiry) {\n\t\treturn false;\n\t}\n\n\t// update inquiry's last message with room's last message to correctly display in the queue\n\t// because we stop updating the inquiry when it's been taken\n\tif (room.lastMessage) {\n\t\tawait LivechatInquiry.setLastMessageById(inquiry._id, room.lastMessage);\n\t}\n\n\tconst transferredBy = normalizeTransferredByData(user, room);\n\tlivechatLogger.debug({ msg: 'Transferring room by user', roomId: room._id, transferredBy: transferredBy._id });\n\tconst transferData = { scope: 'queue' as const, departmentId, transferredBy, ...overrideTransferData };\n\ttry {\n\t\tawait saveTransferHistory(room, transferData);\n\t\tawait RoutingManager.unassignAgent(inquiry, departmentId);\n\t} catch (err) {\n\t\tlivechatLogger.error({ err });\n\t\tthrow new Meteor.Error('error-returning-inquiry');\n\t}\n\n\tcallbacks.runAsync('livechat:afterReturnRoomAsInquiry', { room });\n\n\treturn true;\n}\n\nexport async function removeOmnichannelRoom(rid: string) {\n\tlivechatLogger.debug({ msg: 'Deleting room', roomId: rid });\n\tcheck(rid, String);\n\tconst room = await LivechatRooms.findOneById(rid);\n\tif (!room) {\n\t\tthrow new Meteor.Error('error-invalid-room', 'Invalid room');\n\t}\n\n\tif (!isOmnichannelRoom(room)) {\n\t\tthrow new Meteor.Error('error-this-is-not-a-livechat-room');\n\t}","sourceCodeStart":244,"sourceCodeEnd":280,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/lib/omnichannel/rooms.ts#L244-L280","documentation":"returnRoomAsInquiry wraps saveTransferHistory and RoutingManager.unassignAgent in one try/catch; any failure in either call is logged via livechatLogger.error({ err }) and re-raised as Meteor.Error('error-returning-inquiry'). It is a wrapper error: the real cause appears only in the server log entry immediately before it.","triggerScenarios":"saveTransferHistory throws (transfer-history write failure) or the configured RoutingManager's unassignAgent throws (custom routing method, auto-selection engine error) while returning a room to the queue.","commonSituations":"Custom routing-method implementation raising; database write errors; regressions in transfer-history handling after a version upgrade.","solutions":["Read the server logs: the livechatLogger.error entry right before this error carries the original exception — fix that root cause first.","Reproduce with the workspace's routing method (Administration > Omnichannel > Routing) to isolate custom routing code.","Retry after the underlying fix; both calls run inside the same try block, so a partial state is possible and the room should be re-checked."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n\tawait returnRoomAsInquiry(room, departmentId);\n} catch (err) {\n\tif (err instanceof Meteor.Error && err.error === 'error-returning-inquiry') {\n\t\t// inspect server logs: livechatLogger.error({ err }) logged the underlying cause\n\t\t// room state may be partially updated - re-fetch before any retry\n\t\treturn;\n\t}\n\tthrow err;\n}","preventionTips":["Always pair this error with a server-log review — the root cause is the logged inner err, not this code.","Test custom routing methods against return-to-queue flows before deploying them.","After upgrades, regression-test transfer history and unassignment paths."],"tags":["omnichannel","livechat","queue","routing","wrapped-error"],"backgroundTag":"operation-wrapped-error","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","contentChangedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}