{"record":{"id":"b354a1ad23f32e38","repo":"RocketChat/Rocket.Chat","slug":"error-transferring-inquiry","errorCode":"error-transferring-inquiry","errorMessage":"error-transferring-inquiry","messagePattern":"error-transferring-inquiry","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"apps/meteor/server/lib/omnichannel/Helper.ts","lineNumber":642,"sourceCode":"\t\treturn false;\n\t}\n\tlogger.debug({\n\t\tmsg: 'Attempting to forward room to department',\n\t\troomId: room._id,\n\t\tdepartmentId: transferData.departmentId,\n\t});\n\n\tawait callbacks.run('livechat.beforeForwardRoomToDepartment', { room, transferData });\n\tconst { _id: rid, servedBy: oldServedBy, departmentId: oldDepartmentId } = room;\n\tlet agent = null;\n\n\tconst inquiry = await LivechatInquiry.findOneByRoomId(rid, {});\n\tif (!inquiry) {\n\t\tlogger.debug({\n\t\t\tmsg: 'Cannot forward room. No inquiries found',\n\t\t\troomId: room._id,\n\t\t});\n\t\tthrow new Error('error-transferring-inquiry');\n\t}\n\n\tconst { departmentId } = transferData;\n\tif (!departmentId) {\n\t\tlogger.debug({\n\t\t\tmsg: 'Cannot forward room. No departmentId provided',\n\t\t\troomId: room._id,\n\t\t});\n\t\tthrow new Error('error-transferring-inquiry-no-department');\n\t}\n\tif (oldDepartmentId === departmentId) {\n\t\tthrow new Error('error-forwarding-chat-same-department');\n\t}\n\n\tconst { userId: agentId, clientAction } = transferData;\n\tif (agentId) {\n\t\tlogger.debug({\n\t\t\tmsg: 'Forwarding room to department and user',","sourceCodeStart":624,"sourceCodeEnd":660,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/lib/omnichannel/Helper.ts#L624-L660","documentation":"The department-forward path throws error-transferring-inquiry when LivechatInquiry.findOneByRoomId finds no inquiry for the room. Same root cause as error-invalid-inquiry on the agent path (dequeued/closed/consumed inquiry), but a distinct error code so callers can tell which forward API failed.","triggerScenarios":"livechat/room.forward with only departmentId on a room whose inquiry was already consumed by a previous transfer; room closed concurrently; duplicate department-forward submissions.","commonSituations":"Racing transfer requests from two supervisors; chat closed while the transfer dialog was open; retry of an already-completed transfer.","solutions":["Re-check that the room is open and has an inquiry, then retry once","Prevent duplicate submissions in the transfer UI","If the room needs routing again, put it back in the queue instead of forwarding"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const inquiry = await LivechatInquiry.findOneByRoomId(room._id, { projection: { _id: 1 } });\nif (!inquiry || !room.open) {\n  // nothing to forward; re-queue or abort instead of calling the transfer\n}","typeGuard":null,"tryCatchPattern":"try {\n  await forwardRoomToDepartment(room, transferData, guest);\n} catch (err) {\n  if (err instanceof Error && err.message === 'error-transferring-inquiry') {\n    // inquiry gone: refresh and retry at most once if the room is still open\n  } else throw err;\n}","preventionTips":["One in-flight transfer per room; guard against double submits","Handle chat-closed events by invalidating open transfer dialogs"],"tags":["omnichannel","livechat","inquiry","transfer","department","rocket-chat"],"backgroundTag":"entity-not-found","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}