{"record":{"id":"6bc672c6795671f4","repo":"RocketChat/Rocket.Chat","slug":"invalid-user","errorCode":null,"errorMessage":"Invalid user","messagePattern":"Invalid user","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/app/apps/server/bridges/rooms.ts","lineNumber":100,"sourceCode":"\t\tdelete extraData.t;\n\t\tdelete extraData.ro;\n\t\tdelete extraData.customFields;\n\n\t\treturn extraData;\n\t}\n\n\tprivate async createChannel(userId: string, room: ICoreRoom, members: string[]): Promise<string> {\n\t\treturn (await createChannelMethod(userId, room.name || '', members, room.ro, room.customFields, this.prepareExtraData(room))).rid;\n\t}\n\n\tprivate async createDirectMessage(userId: string, members: string[]): Promise<string> {\n\t\treturn (await createDirectMessage(members, userId)).rid;\n\t}\n\n\tprivate async createPrivateGroup(userId: string, room: ICoreRoom, members: string[]): Promise<string> {\n\t\tconst user = await Users.findOneById(userId);\n\t\tif (!user) {\n\t\t\tthrow new Error('Invalid user');\n\t\t}\n\t\treturn (await createPrivateGroupMethod(user, room.name || '', members, room.ro, room.customFields, this.prepareExtraData(room))).rid;\n\t}\n\n\tprotected async getById(roomId: string, appId: string): Promise<IRoom> {\n\t\tthis.orch.debugLog(`The App ${appId} is getting the roomById: \"${roomId}\"`);\n\n\t\t// #TODO: #AppsEngineTypes - Remove explicit types and typecasts once the apps-engine definition/implementation mismatch is fixed.\n\t\tconst promise: Promise<IRoom | undefined> = this.orch.getConverters()?.get('rooms').convertById(roomId);\n\t\treturn promise as Promise<IRoom>;\n\t}\n\n\tprotected async getByName(roomName: string, appId: string): Promise<IRoom> {\n\t\tthis.orch.debugLog(`The App ${appId} is getting the roomByName: \"${roomName}\"`);\n\n\t\t// #TODO: #AppsEngineTypes - Remove explicit types and typecasts once the apps-engine definition/implementation mismatch is fixed.\n\t\tconst promise: Promise<IRoom | undefined> = this.orch.getConverters()?.get('rooms').convertByName(roomName);\n\t\treturn promise as Promise<IRoom>;","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/f9d3ec372bb580fa8d036f94cf03925a478ef768/apps/meteor/app/apps/server/bridges/rooms.ts#L82-L118","documentation":"Thrown by AppRoomBridge.createPrivateGroup when Users.findOneById(room.creator.id) returns null. The private-group creation server method requires a full user document (not just an id), so the bridge refuses to proceed when the creator id does not resolve to a persisted user. Note that the channel and direct-message branches do not perform this lookup, so the error is specific to private-group creation.","triggerScenarios":"An App creates a private group with room.creator.id set to a user id that does not exist — a deleted user, a federated user not yet mirrored locally, an id from a stale cache, or a placeholder id assigned before the user was provisioned.","commonSituations":"Holding a user id from a previous workspace state; acting on a webhook whose actor was deleted; federation/matrix users whose local document lags; creating a room as a bot user that was never inserted.","solutions":["Verify the creator id resolves to a user (via the users accessor) before calling create with RoomType.PRIVATE_GROUP.","Use a known-good bot user id as the creator; ensure the App's bot user is provisioned.","If the creator was deleted, prompt for a valid owner or fall back to the App's own user."],"exampleFix":"// before\nroom.setCreator({ id: maybeDeletedUserId });\nroom.setType(RoomType.PRIVATE_GROUP);\nawait modify.getCreator().startRoom(room).done();\n\n// after\nconst creator = await users.getById(maybeDeletedUserId);\nif (!creator) throw new Error('Creator user not found');\nroom.setCreator({ id: creator.id });\nawait modify.getCreator().startRoom(room).done();","handlingStrategy":"validation","validationCode":"const creator = await users.getById(room.creator.id);\nif (!creator) {\n  throw new Error(`Cannot create private group: creator ${room.creator.id} does not exist`);\n}\nroom.setCreator({ id: creator.id });\nawait modify.getCreator().startRoom(room).done();","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Resolve the creator via the users accessor before building the room for a private group.","Use the App's own bot user as a stable creator when in doubt.","Refresh user ids from a fresh read rather than trusting cached references."],"tags":["apps-engine","room-bridge","validation","user-lookup","private-group"],"backgroundTag":null,"analyzedSha":"f9d3ec372bb580fa8d036f94cf03925a478ef768","analyzedAt":"2026-08-12T19:07:17.372Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}