RocketChat/Rocket.Chat · error · Meteor.Error

invalid-room

invalid-room

Error message

Invalid room

What it means

Thrown by saveRoomDescription when Match.test(rid, String) fails (saveRoomDescription.ts:10). Pure argument-type gate before Rooms.setDescriptionById; no system message is written when it throws. Code 'invalid-room', details { function: 'RocketChat.saveRoomDescription' }.

Source

Thrown at apps/meteor/server/lib/rooms/settings/saveRoomDescription.ts:10

import { Message } from '@rocket.chat/core-services';
import type { IUser } from '@rocket.chat/core-typings';
import { Rooms } from '@rocket.chat/models';
import { Match } from 'meteor/check';
import { Meteor } from 'meteor/meteor';
import type { UpdateResult } from 'mongodb';

export const saveRoomDescription = async function (rid: string, roomDescription: string, user: IUser): Promise<UpdateResult> {
	if (!Match.test(rid, String)) {
		throw new Meteor.Error('invalid-room', 'Invalid room', {
			function: 'RocketChat.saveRoomDescription',
		});
	}

	const update = await Rooms.setDescriptionById(rid, roomDescription);
	await Message.saveSystemMessage('room_changed_description', rid, roomDescription, user);
	return update;
};

View on GitHub (pinned to b2c16d5842)

Solutions

  1. Pass room._id as a string
  2. Type-check at the API boundary before calling
  3. Search for the call site and confirm which variable is actually passed
  4. Add a unit test asserting the guard fires for non-string input so regressions surface clearly

Example fix

// before
await saveRoomDescription(room, description, user);

// after
await saveRoomDescription(room._id, description, user);
Defensive patterns

Strategy: type-guard

Validate before calling

if (typeof rid !== 'string' || rid.length === 0) {
	throw new Meteor.Error('invalid-room', 'Invalid room', { function: 'RocketChat.saveRoomDescription' });
}
await saveRoomDescription(rid, description, user);

Type guard

const isRoomId = (v: unknown): v is string => typeof v === 'string' && v.length > 0;

Prevention

When it happens

Trigger: saveRoomDescription(undefined, text, user) from an unbound form field; passing room object or ObjectId; renamed variable (rid vs roomId) missing one call site.

Common situations: Method/REST wrappers forwarding user input without checks; UI components passing the whole room record; test helpers with placeholder ids.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of RocketChat/Rocket.Chat@b2c16d5842 (2026-08-18). Data as JSON: /api/errors/0fce443d82b17f47. Report an issue: GitHub.