RocketChat/Rocket.Chat · error · Meteor.Error

error-roomid-param-not-provided

error-roomid-param-not-provided

Error message

The parameter "roomId" or "roomName" is required

What it means

Thrown by the shared helper findRoomByIdOrName when neither roomId nor roomName is present in params (or both are present but empty). The helper powers several room endpoints that accept either an id or a name. Returns a structured Meteor.Error('error-roomid-param-not-provided', ...).

Source

Thrown at apps/meteor/server/api/v1/rooms.ts:114

export async function findRoomByIdOrName({
	params,
	checkedArchived = true,
}: {
	params:
		| {
				roomId?: string;
		  }
		| {
				roomName?: string;
		  };
	checkedArchived?: boolean;
}): 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-roomid-param-not-provided', 'The parameter "roomId" or "roomName" is required');
	}

	const projection = { ...API.v1.defaultFieldsToExclude };

	let room;
	if ('roomId' in params) {
		room = await Rooms.findOneById(params.roomId || '', { projection });
	} else if ('roomName' in params) {
		room = await Rooms.findOneByName(params.roomName || '', { projection });
	}

	if (!room) {
		throw new Meteor.Error('error-room-not-found', 'The required "roomId" or "roomName" param provided does not match any channel');
	}
	if (checkedArchived && room.archived) {
		throw new Meteor.Error('error-room-archived', `The channel, ${room.name}, is archived`);
	}

View on GitHub (pinned to f9d3ec372b)

Solutions

  1. Supply exactly one of roomId or roomName as a non-empty string.
  2. Validate at least one identifier is present client-side before the call.
  3. Use roomId when you have the internal id; use roomName for the human-readable channel name.

Example fix

// before
fetch('/api/v1/<endpoint>', { method:'POST', body: JSON.stringify({}) });

// after
if (!roomId && !roomName) throw new Error('roomId or roomName required');
const body = roomId ? { roomId } : { roomName };
fetch('/api/v1/<endpoint>', { method:'POST', body: JSON.stringify(body) });
Defensive patterns

Strategy: validation

Validate before calling

function buildRoomParam(roomId?: string, roomName?: string): { roomId: string } | { roomName: string } {
  if (roomId && roomId.trim()) return { roomId };
  if (roomName && roomName.trim()) return { roomName };
  throw new Error('roomId or roomName is required');
}
const body = buildRoomParam(roomId, roomName);

Type guard

type RoomRef = { roomId: string } | { roomName: string };
function isRoomRef(p: unknown): p is RoomRef {
  if (typeof p !== 'object' || p === null) return false;
  const o = p as Record<string, unknown>;
  return (typeof o.roomId === 'string' && o.roomId.length > 0) || (typeof o.roomName === 'string' && o.roomName.length > 0);
}

Prevention

When it happens

Trigger: Calling an endpoint backed by findRoomByIdOrName with a body/query containing neither roomId nor roomName, or containing both as empty strings.

Common situations: Client conditionally builds params and sends an empty object; both fields left blank in a form; param name typo (e.g. room instead of roomName).

Related errors


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