RocketChat/Rocket.Chat · error · Meteor.Error

error-room-param-not-provided

error-room-param-not-provided

Error message

The parameter "roomId" or "roomName" is required

What it means

Thrown by getRoomFromParams, the helper behind the groups.* endpoints, when neither 'roomId' nor 'roomName' is supplied, or both are present but empty strings. At least one non-empty identifier is required to locate the private group.

Source

Thrown at apps/meteor/server/api/v1/groups.ts:73

import { leaveRoomMethod } from '../../meteor-methods/rooms/leaveRoom';
import { removeRoomLeader } from '../../meteor-methods/rooms/removeRoomLeader';
import { removeRoomModerator } from '../../meteor-methods/rooms/removeRoomModerator';
import { removeRoomOwner } from '../../meteor-methods/rooms/removeRoomOwner';
import { removeUserFromRoomMethod } from '../../meteor-methods/rooms/removeUserFromRoom';
import { saveRoomSettings } from '../../meteor-methods/rooms/saveRoomSettings';
import { executeUnarchiveRoom } from '../../meteor-methods/rooms/unarchiveRoom';
import { API } from '../api';
import { addUserToFileObj } from '../lib/addUserToFileObj';
import { composeRoomWithLastMessage } from '../lib/composeRoomWithLastMessage';
import { getPaginationItems } from '../lib/getPaginationItems';
import { getUserFromParams, getUserListFromParams, getUsernameListFromParams } from '../lib/getUserFromParams';

async function getRoomFromParams(params: { roomId?: string } | { roomName?: string }): Promise<IRoom> {
	if (
		(!('roomId' in params) && !('roomName' in params)) ||
		('roomId' in params && !(params as { roomId?: string }).roomId && 'roomName' in params && !(params as { roomName?: string }).roomName)
	) {
		throw new Meteor.Error('error-room-param-not-provided', 'The parameter "roomId" or "roomName" is required');
	}

	const roomOptions = {
		projection: {
			...roomAccessAttributes,
			t: 1,
			ro: 1,
			name: 1,
			fname: 1,
			prid: 1,
			archived: 1,
			broadcast: 1,
		},
	};

	const room = await (() => {
		if ('roomId' in params) {
			return Rooms.findOneById(params.roomId || '', roomOptions);

View on GitHub (pinned to f9d3ec372b)

Solutions

  1. Pass exactly one of roomId or roomName as a non-empty string.
  2. Validate client-side that at least one identifier is present before the call.
  3. If both are known, prefer roomId (direct lookup) over roomName.

Example fix

// before
const url = `/api/v1/groups.info?roomId=${rid ?? ''}&roomName=${rname ?? ''}`;
// after
const id = rid ?? rname;
if (!id) throw new Error('roomId or roomName required');
const url = rid ? `/api/v1/groups.info?roomId=${encodeURIComponent(rid)}` : `/api/v1/groups.info?roomName=${encodeURIComponent(rname)}`;
Defensive patterns

Strategy: validation

Validate before calling

function requireRoomIdOrName(params) {
  const id = ('roomId' in params && params.roomId) || ('roomName' in params && params.roomName);
  if (!id) throw new Error('roomId or roomName required');
  return id;
}

Type guard

function hasRoomIdentifier(p): p is { roomId?: string; roomName?: string } {
  return (!!p && typeof p === 'object') && (!!p.roomId || !!p.roomName);
}

Try / catch

try { await groupsInfo({ roomId }); }
catch (e) {
  if (isApiError(e, 'error-room-param-not-provided')) { /* require a selection */) }
  else throw e;
}

Prevention

When it happens

Trigger: Calling groups.info / groups.members / etc. with no roomId and no roomName; both passed as empty strings; client submits the form without selecting a room.

Common situations: UI form submitted before a room was chosen; URL builder ran with undefined for both; query-string parsing dropped both params.

Related errors


AI-assisted analysis of RocketChat/Rocket.Chat@f9d3ec372b (2026-08-12). Data as JSON: /api/errors/4f3f4962dfe330fa. Report an issue: GitHub.