RocketChat/Rocket.Chat · error
roomId was not provided.
Error message
roomId was not provided.
What it means
Guard in the rooms bridge removeUsers: the roomId argument is falsy, so the bridge refuses to run removeUserFromRoom for the given usernames. Rocket.Chat addresses rooms solely by their _id, and an empty id would match nothing or the wrong document.
Solutions
- Pass the id of an existing room, taken from the triggering context (message.room.id or the interaction's room).
- Validate required parameters at handler entry and fail fast with a clear message.
- If the room may be gone, check it via the room reader before removing users.
Example fix
// before
await removeUsers(params.room ?? '', usernames, appId);
// after
const roomId = context.getRoom()?.id;
if (!roomId) {
throw new Error('A room is required to remove users');
}
await removeUsers(roomId, usernames, appId); Defensive patterns
Strategy: validation
Validate before calling
const roomId = context.getRoom()?.id ?? message.room.id;
if (!roomId) {
throw new Error('roomId is required to remove users');
} Type guard
const isNonEmptyString = (v: unknown): v is string => typeof v === 'string' && v.trim().length > 0;
Prevention
- Validate required params at handler entry.
- Read room ids from the live context, not from optional user input.
- Fail fast with a clear message instead of forwarding empty ids.
When it happens
Trigger: App calls removeUsers with roomId as '', undefined, or null — typically from an unset slash-command parameter, a misnamed parameter (rid vs roomId), or destructuring a field that is not present.
Common situations: Slash commands and UIKit handlers reading the room id from the wrong context property; optional parameters used without validation; renames during refactors leaving an undefined variable.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- Invalid user id
- There must be a parent room to create a discussion.
- User not provided
- User not subscribed to room
- A new user type has been added that the Apps don't know…
AI-assisted analysis of RocketChat/Rocket.Chat@b2c16d5842 (2026-08-18).
Data as JSON: /api/errors/b23341464ce5eaa6.
Report an issue: GitHub.
Appendix: source
Thrown at apps/meteor/app/apps/server/bridges/rooms.ts:379
if (!subscription) {
const errorMessage = `No subscription found for user with ID "${uid}" in room with ID "${roomId}". This means the user is not subscribed to the room.`;
this.orch.debugLog(errorMessage);
throw new Error('User not subscribed to room');
}
const lastSeen = subscription?.ls;
if (!lastSeen) {
return 0;
}
return Messages.countVisibleByRoomIdBetweenTimestampsNotContainingTypes(roomId, lastSeen, new Date(), []);
}
protected async removeUsers(roomId: string, usernames: Array<string>, appId: string): Promise<void> {
this.orch.debugLog(`The App ${appId} is removing users ${usernames} from room id: ${roomId}`);
if (!roomId) {
throw new Error('roomId was not provided.');
}
const members = await Users.findUsersByUsernames(usernames, { limit: 50 }).toArray();
await Promise.all(members.map((user) => removeUserFromRoom(roomId, user)));
}
}
View on GitHub (pinned to b2c16d5842)