{"record":{"id":"401da4c724330134","repo":"RocketChat/Rocket.Chat","slug":"missing-userid","errorCode":null,"errorMessage":"missing-userId","messagePattern":"missing-userId","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/services/team/service.ts","lineNumber":321,"sourceCode":"\t\tif (options === undefined) {\n\t\t\treturn Team.findByNames(names).toArray();\n\t\t}\n\t\treturn Team.findByNames(names, options).toArray();\n\t}\n\n\tasync listByIds(ids: Array<string>, options?: FindOptions<ITeam>): Promise<ITeam[]> {\n\t\treturn Team.findByIds(ids, options).toArray();\n\t}\n\n\tasync addRooms(uid: string, rooms: Array<string>, teamId: string): Promise<Array<IRoom>> {\n\t\tif (!teamId) {\n\t\t\tthrow new Error('missing-teamId');\n\t\t}\n\t\tif (!rooms) {\n\t\t\tthrow new Error('missing-rooms');\n\t\t}\n\t\tif (!uid) {\n\t\t\tthrow new Error('missing-userId');\n\t\t}\n\n\t\tconst team = await Team.findOneById<Pick<ITeam, '_id' | 'roomId'>>(teamId, { projection: { _id: 1, roomId: 1 } });\n\t\tif (!team) {\n\t\t\tthrow new Error('invalid-team');\n\t\t}\n\n\t\t// at this point, we already checked for the permission\n\t\t// so we just need to check if the user can see the room\n\t\tconst user = await Users.findOneById(uid);\n\t\tif (!user) {\n\t\t\tthrow new Error('invalid-user');\n\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');","sourceCodeStart":303,"sourceCodeEnd":339,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/e4b8178b205510181a96ceefee043d0abcd13e5a/apps/meteor/server/services/team/service.ts#L303-L339","documentation":"Error \"missing-userId\" thrown in RocketChat/Rocket.Chat.","triggerScenarios":"Thrown at apps/meteor/server/services/team/service.ts:319 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the caller is authenticated so a valid user id (uid) is passed to the team service.","Verify the session token is valid and has not expired before calling addRooms or removeRoom."],"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-14T00:17:10.932Z"}