RocketChat/Rocket.Chat · error · Meteor.Error
error-invalid-room
error-invalid-room
Error message
Invalid room
What it means
Thrown by the 'getRoomByTypeAndName' Meteor method when either the room type or the room name argument is falsy. Both are required to locate a room (type selects the room-type-specific finder, name is the lookup key). The error is reported as 'error-invalid-room' with method 'getRoomByTypeAndName'.
Source
Thrown at apps/meteor/server/publications/room/index.ts:55
if (updatedAt instanceof Date) {
return {
update: await (await Rooms.findBySubscriptionUserIdUpdatedAfter(userId, updatedAt, options)).toArray(),
remove: await Rooms.trashFindDeletedAfter(updatedAt, {}, { projection: { _id: 1, _deletedAt: 1 } }).toArray(),
};
}
return (await Rooms.findBySubscriptionUserId(userId, options)).toArray();
};
Meteor.methods<ServerMethods>({
async 'rooms/get'(updatedAt) {
return roomsGetMethod(Meteor.userId(), updatedAt);
},
async 'getRoomByTypeAndName'(type, name) {
if (!type || !name) {
throw new Meteor.Error('error-invalid-room', 'Invalid room', {
method: 'getRoomByTypeAndName',
});
}
const user = await Meteor.userAsync();
const isAnonymous = !user?._id;
if (isAnonymous) {
const allowAnon = settings.get('Accounts_AllowAnonymousRead');
if (!allowAnon || type !== 'c') {
throw new Meteor.Error('error-invalid-user', 'Invalid user', {
method: 'getRoomByTypeAndName',
});
}
}
const roomFind = roomCoordinator.getRoomFind(type);
View on GitHub (pinned to b2c16d5842)
Solutions
- Pass both arguments: type must be a room-type string like 'c', 'p', 'd' or 'l', name the room identifier
- Validate the inputs at the call site before invoking the method
- Parse room type and name from the route before calling
Example fix
// before
Meteor.call('getRoomByTypeAndName', roomType, name ?? '');
// after
if (!roomType || !name) return;
Meteor.call('getRoomByTypeAndName', roomType, name); Defensive patterns
Strategy: validation
Validate before calling
if (!type || !name) {
throw new Error('type and name are required');
}
Meteor.call('getRoomByTypeAndName', type, name); Type guard
const ROOM_TYPES = new Set(['c', 'p', 'd', 'l', 't']);
function isRoomType(v: unknown): v is 'c' | 'p' | 'd' | 'l' | 't' {
return typeof v === 'string' && ROOM_TYPES.has(v);
} Prevention
- Parse both values from the route and skip the call when either is absent
- Keep argument order (type, name) consistent across wrappers
When it happens
Trigger: Meteor.call('getRoomByTypeAndName', undefined, 'general'); calling with type '' or name '' ; building the call from optional route params that were never filled.
Common situations: Deep links like /channel/ handled before parsing; lookups where the type letter (c/p/d/l) is missing; refactors that swap argument order and pass undefined.
Understand the failure class
Background: Missing required parameter errors: what 'X is required' and 'the required X param is missing' mean, and how to fix them — this error's family across 27 libraries.
Related errors
- error-invalid-room-name
- error-message-same-as-tmid
- error-message-change-to-thread
- error-invalid-payload
- error-invalid-room
AI-assisted analysis of RocketChat/Rocket.Chat@b2c16d5842 (2026-08-18).
Data as JSON: /api/errors/fabe6aa447a61785.
Report an issue: GitHub.