{"record":{"id":"170cabe35a072b8c","repo":"RocketChat/Rocket.Chat","slug":"invalid-agentid","errorCode":null,"errorMessage":"Invalid agentId","messagePattern":"Invalid agentId","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/app/apps/server/bridges/livechat.ts","lineNumber":164,"sourceCode":"\t\tconst visitor = this.orch.getConverters()?.get('visitors').convertAppVisitor(room.visitor);\n\n\t\tconst closeData: any = {\n\t\t\troom: await this.orch.getConverters()?.get('rooms').convertAppRoom(room),\n\t\t\tcomment,\n\t\t\t...(user && { user }),\n\t\t\t...(visitor && { visitor }),\n\t\t};\n\n\t\tawait closeRoom(closeData);\n\n\t\treturn true;\n\t}\n\n\tprotected async findOpenRoomsByAgentId(agentId: string, appId: string): Promise<ILivechatRoom[]> {\n\t\tthis.orch.debugLog(`The App ${appId} is looking for livechat rooms associated with agent ${agentId}`);\n\n\t\tif (!agentId) {\n\t\t\tthrow new Error('Invalid agentId');\n\t\t}\n\n\t\tconst rooms = await LivechatRooms.findOpenByAgent(agentId).toArray();\n\t\treturn Promise.all(rooms.map((room) => this.orch.getConverters()?.get('rooms').convertRoom(room) as Promise<ILivechatRoom>));\n\t}\n\n\tprotected async countOpenRoomsByAgentId(agentId: string, appId: string): Promise<number> {\n\t\tthis.orch.debugLog(`The App ${appId} is counting livechat rooms associated with agent ${agentId}`);\n\n\t\tif (!agentId) {\n\t\t\tthrow new Error('Invalid agentId');\n\t\t}\n\n\t\treturn LivechatRooms.countOpenByAgent(agentId);\n\t}\n\n\tprotected async findRooms(visitor: IVisitor, departmentId: string | null, appId: string): Promise<Array<ILivechatRoom>> {\n\t\tthis.orch.debugLog(`The App ${appId} is looking for livechat visitors.`);","sourceCodeStart":146,"sourceCodeEnd":182,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/2a7de457074cbb4d4373fbd9a4e5bea292c9c764/apps/meteor/app/apps/server/bridges/livechat.ts#L146-L182","documentation":"Error \"Invalid agentId\" thrown in RocketChat/Rocket.Chat.","triggerScenarios":"Thrown at apps/meteor/app/apps/server/bridges/livechat.ts:164 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass a non-empty agentId string when looking up open rooms by agent.","Check the caller supplies a valid agent id before invoking findOpenRoomsByAgentId."],"exampleFix":"Guard the agentId parameter: if (!agentId || typeof agentId !== 'string') { throw new Error('Invalid agentId'); }","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2a7de457074cbb4d4373fbd9a4e5bea292c9c764","analyzedAt":"2026-08-18T15:26:39.429Z","contentChangedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}