{"record":{"id":"0322084982d8d79d","repo":"RocketChat/Rocket.Chat","slug":"no-inquiry-or-agent-provided","errorCode":null,"errorMessage":"No inquiry or agent provided","messagePattern":"No inquiry or agent provided","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/ee/server/hooks/omnichannel/checkAgentBeforeTakeInquiry.ts","lineNumber":31,"sourceCode":"}: {\n\tagent: {\n\t\tagentId: string;\n\t};\n\tinquiry: {\n\t\t_id: string;\n\t\tdepartment: string;\n\t};\n\toptions: {\n\t\tforwardingToDepartment?: {\n\t\t\toldDepartmentId: string;\n\t\t\ttransferData: any;\n\t\t};\n\t\tclientAction?: boolean;\n\t};\n}) => {\n\tif (!inquiry?._id || !agent?.agentId) {\n\t\tcbLogger.debug('No inquiry or agent provided');\n\t\tthrow new Error('No inquiry or agent provided');\n\t}\n\tconst { agentId } = agent;\n\n\tif (!(await checkOnlineAgents(undefined, agent))) {\n\t\tcbLogger.debug('Provided agent is not online');\n\t\tthrow new Error('Provided agent is not online');\n\t}\n\n\tif (!settings.get('Livechat_waiting_queue')) {\n\t\tcbLogger.info({ msg: 'Chat can be taken by Agent: waiting queue is disabled', agentId });\n\t\treturn agent;\n\t}\n\n\tif (await allowAgentSkipQueue(agent)) {\n\t\tcbLogger.info({ msg: 'Chat can be taken by Agent: agent can skip queue', agentId });\n\t\treturn agent;\n\t}\n","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/f9d3ec372bb580fa8d036f94cf03925a478ef768/apps/meteor/ee/server/hooks/omnichannel/checkAgentBeforeTakeInquiry.ts#L13-L49","documentation":"Thrown by the `livechat.checkAgentBeforeTakeInquiry` callback (`validateMaxChats`) when `inquiry._id` or `agent.agentId` is missing. It is a plain `Error`; the callback logs at debug level before throwing. It guards the take-inquiry flow against incomplete input.","triggerScenarios":"The take-inquiry callback is invoked with an `inquiry` lacking `_id` and/or an `agent` lacking `agentId` (undefined/null).","commonSituations":"Caller forgot to populate the inquiry or agent object; upstream lookup returned null and was passed through unchecked; race where inquiry was deleted before take action.","solutions":["Ensure both `inquiry._id` and `agent.agentId` are populated before invoking the take-inquiry flow.","Validate inputs at the calling boundary and return early with a clear message if missing.","Re-fetch the inquiry/agent if they may have been removed."],"exampleFix":"// before\nconst result = await callbacks.run('livechat.checkAgentBeforeTakeInquiry', inquiry, agent);\n\n// after\nif (!inquiry?._id || !agent?.agentId) {\n\tthrow new Error('Cannot take inquiry: inquiry id and agent id are required');\n}\nconst result = await callbacks.run('livechat.checkAgentBeforeTakeInquiry', inquiry, agent);","handlingStrategy":"validation","validationCode":"function hasInquiryAndAgent(inquiry: { _id?: string } | undefined, agent: { agentId?: string } | undefined): boolean {\n\treturn Boolean(inquiry?._id && agent?.agentId);\n}","typeGuard":"function isNoInquiryOrAgentError(e: unknown): boolean {\n\treturn e instanceof Error && e.message === 'No inquiry or agent provided';\n}","tryCatchPattern":"try {\n\tawait callbacks.run('livechat.checkAgentBeforeTakeInquiry', inquiry, agent);\n} catch (e) {\n\tif (e instanceof Error && e.message === 'No inquiry or agent provided') {\n\t\t// populate inquiry._id and agent.agentId\n\t}\n\tthrow e;\n}","preventionTips":["Populate `inquiry._id` and `agent.agentId` before the take-inquiry flow.","Validate inputs at the calling boundary.","Re-fetch inquiry/agent if they may have been removed."],"tags":["omnichannel","livechat","validation","ee"],"backgroundTag":null,"analyzedSha":"f9d3ec372bb580fa8d036f94cf03925a478ef768","analyzedAt":"2026-08-12T19:07:17.372Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}