{"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/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/ee/server/hooks/omnichannel/checkAgentBeforeTakeInquiry.ts#L13-L49","documentation":"Plain Error thrown by the validateMaxChats handler on 'livechat.checkAgentBeforeTakeInquiry' when the callback is invoked without a usable inquiry (missing inquiry._id) or agent (missing agent.agentId). It is a contract violation of the internal callback signature, not a user-capacity condition.","triggerScenarios":"Server code or an app calling callbacks.run('livechat.checkAgentBeforeTakeInquiry', ...) with undefined/null inquiry or agent objects, or objects shaped without _id/agentId; take-inquiry flows where the inquiry was already dequeued before the check ran.","commonSituations":"Custom enterprise logic invoking the take-inquiry callback directly; race between waiting-queue processing and the take action removing the inquiry; refactors that changed the callback payload shape.","solutions":["Pass a fully populated inquiry (with _id) and agent (with agentId) when running the callback","Re-fetch the inquiry by rid right before taking it, so a just-dequeued inquiry surfaces as 'not found' rather than an empty payload","If writing custom code, call the higher-level take-inquiry service instead of the raw callback"],"exampleFix":"// before: invoking the callback with possibly-empty payloads\nawait callbacks.run('livechat.checkAgentBeforeTakeInquiry', inquiry, agent);\n\n// after: guard the contract the hook enforces\nif (!inquiry?._id || !agent?.agentId) {\n  throw new Error('inquiry and agent are required to take an inquiry');\n}\nawait callbacks.run('livechat.checkAgentBeforeTakeInquiry', inquiry, agent);","handlingStrategy":"validation","validationCode":"const canRunTakeCheck = (inquiry?: { _id?: string }, agent?: { agentId?: string }): boolean =>\n  Boolean(inquiry?._id && agent?.agentId);","typeGuard":"const hasTakeInquiryPayload = (\n  payload: unknown,\n): payload is { inquiry: { _id: string }; agent: { agentId: string } } => {\n  if (typeof payload !== 'object' || payload === null) return false;\n  const p = payload as any;\n  return typeof p?.inquiry?._id === 'string' && typeof p?.agent?.agentId === 'string';\n};","tryCatchPattern":"try {\n  await callbacks.run('livechat.checkAgentBeforeTakeInquiry', inquiry, agent);\n} catch (err: any) {\n  if (err?.message === 'No inquiry or agent provided') {\n    // refill inquiry/agent from fresh queries; this is a payload bug, not a retry case\n  }\n  throw err;\n}","preventionTips":["Never invoke the take-inquiry callback without a freshly loaded inquiry and agent","Type the callback payload at call sites so missing fields fail at compile time","Distinguish payload errors from capacity errors in take-inquiry error handling"],"tags":["omnichannel","livechat","callback-contract","missing-parameters"],"backgroundTag":"missing-required-argument","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"}