RocketChat/Rocket.Chat · error · Meteor.Error
error-invalid-room
error-invalid-room
Error message
Invalid room
What it means
Inside addAllUserToRoomFn, Rooms.findOneById(rid) returned null, so the room id passed to addAllUserToRoom does not exist. Ordering matters: the permission and user-limit checks run first, then this lookup, then beforeAddUserToRoom and the per-user join loop - so a caller hitting this error already passed 403 and the limit check.
Source
Thrown at apps/meteor/server/meteor-methods/rooms/addAllUserToRoom.ts:50
}
const userFilter: {
active?: boolean;
} = {};
if (activeUsersOnly === true) {
userFilter.active = true;
}
const users = await Users.find(userFilter).toArray();
if (users.length > settings.get<number>('API_User_Limit')) {
throw new Meteor.Error('error-user-limit-exceeded', 'User Limit Exceeded', {
method: 'addAllToRoom',
});
}
const room = await Rooms.findOneById(rid);
if (!room) {
throw new Meteor.Error('error-invalid-room', 'Invalid room', {
method: 'addAllToRoom',
});
}
await beforeAddUserToRoom(
users.map((u) => u.username!),
room,
);
const now = new Date();
for await (const user of users) {
const subscription = await Subscriptions.findOneByRoomIdAndUserId(rid, user._id);
if (subscription != null) {
continue;
}
await callbacks.run('beforeJoinRoom', user, room);
const autoTranslateConfig = getSubscriptionAutotranslateDefaultConfig(user);
const { insertedId } = await Subscriptions.createWithRoomAndUser(room, user, {View on GitHub (pinned to b2c16d5842)
Solutions
- Verify the rid exists first (e.g. GET /v1/channels.info or rooms.info) before the bulk add.
- Catch error-invalid-room and refresh the room list presented to the operator.
- For scripts, resolve rid from a stable identifier (room name) at call time instead of hardcoding.
Defensive patterns
Strategy: validation
Validate before calling
// verify the room exists immediately before the bulk add
const room = await fetch(`/api/v1/channels.info?roomId=${rid}`, { headers }).then((r) => r.json());
if (!room.success) {
throw new Error(`Room ${rid} not found - refresh the room list`);
} Try / catch
try {
await Meteor.callAsync('addAllUserToRoom', rid, activeUsersOnly);
} catch (e: any) {
if (e?.error === 'error-invalid-room') {
// rid is stale: re-resolve the room and re-run with the fresh id
}
} Prevention
- Resolve rids at call time instead of hardcoding them.
- Handle room-deleted events by invalidating cached room references.
- Validate string rids (non-empty, expected format) before any room-scoped call.
When it happens
Trigger: Passing a wrong or truncated rid; the room was deleted (or team channel removed) between the client listing rooms and issuing the call.
Common situations: Stale room pickers in admin UIs; deletion races during room cleanup; hand-built scripts with typos in room ids.
Related errors
AI-assisted analysis of RocketChat/Rocket.Chat@b2c16d5842 (2026-08-18).
Data as JSON: /api/errors/c24169514ab4a4b3.
Report an issue: GitHub.