RocketChat/Rocket.Chat · error · Error

Department not found

Error message

Department ${departmentData._id} not found

What it means

Error "Department ${departmentData._id} not found" thrown in RocketChat/Rocket.Chat.

Solutions

  1. Verify the department id in the event payload refers to an existing livechat department that the department converter can resolve.
  2. Ensure the department still exists (not removed earlier) before the IPostLivechatDepartmentDisabled/Removed listener runs.

Example fix

Validate the department before use: const department = await LivechatDepartment.findOneById(departmentData._id); if (!department) { throw new Error(`Department ${departmentData._id} not found`); }

When it happens

Trigger: Thrown at apps/meteor/app/apps/server/bridges/listeners.ts:491 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of RocketChat/Rocket.Chat@b2c16d5842 (2026-08-18). Data as JSON: /api/errors/48b7591470f058f9. Report an issue: GitHub.

Appendix: source

Thrown at apps/meteor/app/apps/server/bridges/listeners.ts:491

				const [roomId] = args.payload;
				const room = await this.orch.getConverters().get('rooms').convertById(roomId);

				if (!room) {
					throw new Error(`Room with id ${roomId} not found`);
				}

				return this.orch
					.getManager()
					.getListenerManager()
					.executeListener(args.event, room as IAppsLivechatRoom);
			}

			case AppInterface.IPostLivechatDepartmentDisabled: {
				const [departmentData] = args.payload;
				const department = await this.orch.getConverters().get('departments').convertDepartment(departmentData);

				if (!department) {
					throw new Error(`Department ${departmentData._id} not found`);
				}

				return this.orch.getManager().getListenerManager().executeListener(args.event, { department });
			}

			case AppInterface.IPostLivechatDepartmentRemoved: {
				const [departmentData] = args.payload;
				const department = await this.orch.getConverters().get('departments').convertDepartment(departmentData);

				if (!department) {
					throw new Error(`Department ${departmentData._id} not found`);
				}

				return this.orch.getManager().getListenerManager().executeListener(args.event, { department });
			}

			default:
				const [roomData] = args.payload;

View on GitHub (pinned to b2c16d5842)