RocketChat/Rocket.Chat · error · Error
roomId was not provided.
Error message
roomId was not provided.
What it means
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.
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 f9d3ec372b)
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.
Example fix
// before
await modify.getUpdater().removeUsers(maybeRoomId, usernames);
// after
if (!maybeRoomId) {
return;
}
await modify.getUpdater().removeUsers(maybeRoomId, usernames); Defensive patterns
Strategy: validation
Validate before calling
if (!roomId || typeof roomId !== 'string') {
throw new Error('roomId is required to remove users');
} Type guard
function isValidRoomId(id: unknown): id is string {
return typeof id === 'string' && id.trim().length > 0;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- There must be a parent room to create a discussion.
- User not subscribed to room
- User not provided
- Invalid user id
- Invalid Api parameter provided, it must be a valid IApi obje
AI-assisted analysis of RocketChat/Rocket.Chat@f9d3ec372b (2026-08-12).
Data as JSON: /api/errors/b23341464ce5eaa6.
Report an issue: GitHub.