RocketChat/Rocket.Chat · error · Error
Invalid user
Error message
Invalid user
What it means
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.
Source
Thrown at apps/meteor/app/apps/server/bridges/rooms.ts:100
delete extraData.t;
delete extraData.ro;
delete extraData.customFields;
return extraData;
}
private async createChannel(userId: string, room: ICoreRoom, members: string[]): Promise<string> {
return (await createChannelMethod(userId, room.name || '', members, room.ro, room.customFields, this.prepareExtraData(room))).rid;
}
private async createDirectMessage(userId: string, members: string[]): Promise<string> {
return (await createDirectMessage(members, userId)).rid;
}
private async createPrivateGroup(userId: string, room: ICoreRoom, members: string[]): Promise<string> {
const user = await Users.findOneById(userId);
if (!user) {
throw new Error('Invalid user');
}
return (await createPrivateGroupMethod(user, room.name || '', members, room.ro, room.customFields, this.prepareExtraData(room))).rid;
}
protected async getById(roomId: string, appId: string): Promise<IRoom> {
this.orch.debugLog(`The App ${appId} is getting the roomById: "${roomId}"`);
// #TODO: #AppsEngineTypes - Remove explicit types and typecasts once the apps-engine definition/implementation mismatch is fixed.
const promise: Promise<IRoom | undefined> = this.orch.getConverters()?.get('rooms').convertById(roomId);
return promise as Promise<IRoom>;
}
protected async getByName(roomName: string, appId: string): Promise<IRoom> {
this.orch.debugLog(`The App ${appId} is getting the roomByName: "${roomName}"`);
// #TODO: #AppsEngineTypes - Remove explicit types and typecasts once the apps-engine definition/implementation mismatch is fixed.
const promise: Promise<IRoom | undefined> = this.orch.getConverters()?.get('rooms').convertByName(roomName);
return promise as Promise<IRoom>;View on GitHub (pinned to f9d3ec372b)
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.
Example fix
// before
room.setCreator({ id: maybeDeletedUserId });
room.setType(RoomType.PRIVATE_GROUP);
await modify.getCreator().startRoom(room).done();
// after
const creator = await users.getById(maybeDeletedUserId);
if (!creator) throw new Error('Creator user not found');
room.setCreator({ id: creator.id });
await modify.getCreator().startRoom(room).done(); Defensive patterns
Strategy: validation
Validate before calling
const creator = await users.getById(room.creator.id);
if (!creator) {
throw new Error(`Cannot create private group: creator ${room.creator.id} does not exist`);
}
room.setCreator({ id: creator.id });
await modify.getCreator().startRoom(room).done(); Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Only channels, private groups and direct messages can be cre
- Room id not found
- Invalid Api parameter provided, it must be a valid IApi obje
- Invalid command parameter provided, must be a string.
- Invalid Slash Command parameter provided, it must be a valid
AI-assisted analysis of RocketChat/Rocket.Chat@f9d3ec372b (2026-08-12).
Data as JSON: /api/errors/6bc672c6795671f4.
Report an issue: GitHub.