{"record":{"id":"b23341464ce5eaa6","repo":"RocketChat/Rocket.Chat","slug":"roomid-was-not-provided","errorCode":null,"errorMessage":"roomId was not provided.","messagePattern":"roomId was not provided\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/app/apps/server/bridges/rooms.ts","lineNumber":379,"sourceCode":"\n\t\tif (!subscription) {\n\t\t\tconst errorMessage = `No subscription found for user with ID \"${uid}\" in room with ID \"${roomId}\". This means the user is not subscribed to the room.`;\n\t\t\tthis.orch.debugLog(errorMessage);\n\t\t\tthrow new Error('User not subscribed to room');\n\t\t}\n\n\t\tconst lastSeen = subscription?.ls;\n\t\tif (!lastSeen) {\n\t\t\treturn 0;\n\t\t}\n\n\t\treturn Messages.countVisibleByRoomIdBetweenTimestampsNotContainingTypes(roomId, lastSeen, new Date(), []);\n\t}\n\n\tprotected async removeUsers(roomId: string, usernames: Array<string>, appId: string): Promise<void> {\n\t\tthis.orch.debugLog(`The App ${appId} is removing users ${usernames} from room id: ${roomId}`);\n\t\tif (!roomId) {\n\t\t\tthrow new Error('roomId was not provided.');\n\t\t}\n\n\t\tconst members = await Users.findUsersByUsernames(usernames, { limit: 50 }).toArray();\n\t\tawait Promise.all(members.map((user) => removeUserFromRoom(roomId, user)));\n\t}\n}\n","sourceCodeStart":361,"sourceCodeEnd":386,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/f9d3ec372bb580fa8d036f94cf03925a478ef768/apps/meteor/app/apps/server/bridges/rooms.ts#L361-L386","documentation":"Thrown by removeUsers when the roomId argument is falsy. The bridge cannot resolve which room to remove usernames from without an id, so it fails fast before hitting the database.","triggerScenarios":"App calls removeUsers with an empty string, null, or undefined roomId, typically because a variable was not initialized or a room lookup returned nothing upstream.","commonSituations":"roomId sourced from a message or setting that was unexpectedly empty; refactoring left a placeholder; the app acted on a deletion event whose room had already been purged.","solutions":["Validate that roomId is a non-empty string before calling removeUsers.","Resolve roomId from a trusted source and early-return if it is missing.","Add a type-level guard so undefined cannot reach the call site."],"exampleFix":"// before\nawait modify.getUpdater().removeUsers(maybeRoomId, usernames);\n\n// after\nif (!maybeRoomId) {\n  return;\n}\nawait modify.getUpdater().removeUsers(maybeRoomId, usernames);","handlingStrategy":"validation","validationCode":"if (!roomId || typeof roomId !== 'string') {\n  throw new Error('roomId is required to remove users');\n}","typeGuard":"function isValidRoomId(id: unknown): id is string {\n  return typeof id === 'string' && id.trim().length > 0;\n}","tryCatchPattern":null,"preventionTips":["Treat roomId as a required precondition at the handler boundary.","Resolve roomId from a trusted source and skip when missing.","Never forward undefined from a lookup straight into a mutating call."],"tags":["apps-engine","rooms","validation","argument-error"],"backgroundTag":null,"analyzedSha":"f9d3ec372bb580fa8d036f94cf03925a478ef768","analyzedAt":"2026-08-12T19:07:17.372Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}