{"record":{"id":"cd97c033619ccbe9","repo":"RocketChat/Rocket.Chat","slug":"room-already-on-team","errorCode":null,"errorMessage":"room-already-on-team","messagePattern":"room-already-on-team","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/services/team/service.ts","lineNumber":352,"sourceCode":"\t\t}\n\n\t\tconst rids = rooms.filter((rid) => rid && typeof rid === 'string');\n\t\tconst validRooms = await Rooms.findManyByRoomIds(rids).toArray();\n\t\tif (validRooms.length < rids.length) {\n\t\t\tthrow new Error('invalid-room');\n\t\t}\n\n\t\t// validate access for every room first\n\t\tfor await (const room of validRooms) {\n\t\t\tconst canSeeRoom = await Authorization.canAccessRoom(room, user);\n\t\t\tif (!canSeeRoom) {\n\t\t\t\tthrow new Error('invalid-room');\n\t\t\t}\n\t\t}\n\n\t\tfor await (const room of validRooms) {\n\t\t\tif (room.teamId) {\n\t\t\t\tthrow new Error('room-already-on-team');\n\t\t\t}\n\n\t\t\tif (!(await Subscriptions.isUserInRole(uid, 'owner', room._id))) {\n\t\t\t\tthrow new Error('error-no-owner-channel');\n\t\t\t}\n\n\t\t\tif (room.t === 'c') {\n\t\t\t\tawait Message.saveSystemMessage('user-added-room-to-team', team.roomId, room.name || '', user);\n\t\t\t}\n\n\t\t\troom.teamId = teamId;\n\t\t}\n\n\t\tawait Rooms.setTeamByIds(rids, teamId);\n\t\tvoid notifyOnRoomChangedById(rids, 'updated');\n\t\treturn validRooms;\n\t}\n","sourceCodeStart":334,"sourceCodeEnd":370,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/e4b8178b205510181a96ceefee043d0abcd13e5a/apps/meteor/server/services/team/service.ts#L334-L370","documentation":"Error \"room-already-on-team\" thrown in RocketChat/Rocket.Chat.","triggerScenarios":"Thrown at apps/meteor/server/services/team/service.ts:350 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Remove the room from its current team before adding it to a new one.","Check the room's teamId and skip rooms that are already assigned to a team."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e4b8178b205510181a96ceefee043d0abcd13e5a","analyzedAt":"2026-08-18T15:26:39.429Z","contentChangedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}