RocketChat/Rocket.Chat · error · Error
invalid-room
Error message
invalid-room
What it means
Thrown by GET livechat/:rid/messages when LivechatRooms.findOneById(this.urlParams.rid) returns null. The route requires view-l-room permission and validates params via isLivechatRidMessagesProps, but existence of the room is checked here by id lookup.
Source
Thrown at apps/meteor/server/api/v1/omnichannel/visitors.ts:172
}),
);
},
},
);
API.v1.addRoute(
'livechat/:rid/messages',
{ authRequired: true, permissionsRequired: ['view-l-room'], validateParams: isLivechatRidMessagesProps },
{
async get() {
const { offset, count } = await getPaginationItems(this.queryParams);
const { sort } = await this.parseJsonQuery();
const { searchTerm } = this.queryParams;
const room = await LivechatRooms.findOneById(this.urlParams.rid);
if (!room) {
throw new Error('invalid-room');
}
if (!(await canAccessRoomAsync(room, this.user))) {
throw new Error('not-allowed');
}
const { cursor, totalCount } = Messages.findLivechatClosedMessages(this.urlParams.rid, searchTerm, {
sort: sort || { ts: -1 },
skip: offset,
limit: count,
});
const [messages, total] = await Promise.all([cursor.toArray(), totalCount]);
return API.v1.success({
messages: await normalizeMessagesForUser(messages, this.userId),
offset,
count,View on GitHub (pinned to f9d3ec372b)
Solutions
- Re-resolve the rid from the current livechat rooms before fetching messages.
- Filter out stale rids client-side before issuing the request.
- Treat invalid-room on this endpoint as a signal to refresh the room list.
Example fix
null
Defensive patterns
Strategy: validation
Validate before calling
if (!/^[A-Za-z0-9]{17}$/.test(rid)) throw new Error('bad rid');
const room = await fetch(`/api/v1/v1/livechat/${rid}/messages`); Type guard
null
Try / catch
try { await fetch(url); } catch (e) { if (e.error === 'invalid-room') { /* refresh room list, drop stale rid */ } } Prevention
- Resolve rid from a current rooms listing.
- Drop stale rids from pagination cursors.
- Validate rid format client-side.
When it happens
Trigger: GET /api/v1/v1/livechat/<rid>/messages with a rid absent from the rooms collection; rid from a deleted/closed-and-pruned conversation; message id mistakenly used in place of rid.
Common situations: Frontend cached a rid past its lifetime; URL parameter mis-substitution; integration paginating over a rid list that included a stale entry.
Related errors
AI-assisted analysis of RocketChat/Rocket.Chat@f9d3ec372b (2026-08-12).
Data as JSON: /api/errors/a81eed22104211ae.
Report an issue: GitHub.