{"record":{"id":"48b7591470f058f9","repo":"RocketChat/Rocket.Chat","slug":"department-departmentdata-id-not-found","errorCode":null,"errorMessage":"Department ${departmentData._id} not found","messagePattern":"Department (.+?) not found","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/app/apps/server/bridges/listeners.ts","lineNumber":491,"sourceCode":"\t\t\t\tconst [roomId] = args.payload;\n\t\t\t\tconst room = await this.orch.getConverters().get('rooms').convertById(roomId);\n\n\t\t\t\tif (!room) {\n\t\t\t\t\tthrow new Error(`Room with id ${roomId} not found`);\n\t\t\t\t}\n\n\t\t\t\treturn this.orch\n\t\t\t\t\t.getManager()\n\t\t\t\t\t.getListenerManager()\n\t\t\t\t\t.executeListener(args.event, room as IAppsLivechatRoom);\n\t\t\t}\n\n\t\t\tcase AppInterface.IPostLivechatDepartmentDisabled: {\n\t\t\t\tconst [departmentData] = args.payload;\n\t\t\t\tconst department = await this.orch.getConverters().get('departments').convertDepartment(departmentData);\n\n\t\t\t\tif (!department) {\n\t\t\t\t\tthrow new Error(`Department ${departmentData._id} not found`);\n\t\t\t\t}\n\n\t\t\t\treturn this.orch.getManager().getListenerManager().executeListener(args.event, { department });\n\t\t\t}\n\n\t\t\tcase AppInterface.IPostLivechatDepartmentRemoved: {\n\t\t\t\tconst [departmentData] = args.payload;\n\t\t\t\tconst department = await this.orch.getConverters().get('departments').convertDepartment(departmentData);\n\n\t\t\t\tif (!department) {\n\t\t\t\t\tthrow new Error(`Department ${departmentData._id} not found`);\n\t\t\t\t}\n\n\t\t\t\treturn this.orch.getManager().getListenerManager().executeListener(args.event, { department });\n\t\t\t}\n\n\t\t\tdefault:\n\t\t\t\tconst [roomData] = args.payload;","sourceCodeStart":473,"sourceCodeEnd":509,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/app/apps/server/bridges/listeners.ts#L473-L509","documentation":"Error \"Department ${departmentData._id} not found\" thrown in RocketChat/Rocket.Chat.","triggerScenarios":"Thrown at apps/meteor/app/apps/server/bridges/listeners.ts:491 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the department id in the event payload refers to an existing livechat department that the department converter can resolve.","Ensure the department still exists (not removed earlier) before the IPostLivechatDepartmentDisabled/Removed listener runs."],"exampleFix":"Validate the department before use: const department = await LivechatDepartment.findOneById(departmentData._id); if (!department) { throw new Error(`Department ${departmentData._id} not found`); }","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}