RocketChat/Rocket.Chat · error · Meteor.Error

error-room-not-found

error-room-not-found

Error message

The required "roomId" or "roomName" param provided does not match any channel

What it means

Thrown by findChannelByIdOrName when no room matches the given roomId/roomName, or when the matched room's type is neither 'c' (channel) nor 'l' (livechat). This helper backs most channels.* endpoints, so the error appears whenever a caller targets a direct-message room, a private group ('p'), or a non-existent channel through a channels route.

Source

Thrown at apps/meteor/server/api/v1/channels.ts:106

				roomId?: string;
		  }
		| {
				roomName?: string;
		  };
	userId?: string;
	checkedArchived?: boolean;
}): Promise<IRoom> {
	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 || (room.t !== 'c' && room.t !== 'l')) {
		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`);
	}
	if (userId && room.lastMessage) {
		const [lastMessage] = await normalizeMessagesForUser([room.lastMessage], userId);
		room.lastMessage = lastMessage;
	}

	return room;
}

const channelResponseSchema = ajv.compile<{ channel: IRoom }>({
	type: 'object',
	properties: {
		channel: { $ref: '#/components/schemas/IRoom' },
		success: { type: 'boolean', enum: [true] },

View on GitHub (pinned to f9d3ec372b)

Solutions

  1. Use the groups.* or dm.* endpoints if the target is a private group or direct message.
  2. Confirm the room type before routing the call (fetch via rooms.info and branch on room.t).
  3. Double-check the roomId/roomName spelling and that the room still exists.

Example fix

// before
const room = await findChannelByIdOrName({ params: { roomId } });

// after - route by room type
const room = await Rooms.findOneById(roomId);
if (!room) throw new Error('Room not found');
if (room.t === 'p') {
  return callGroupsEndpoint(roomId);
}
if (room.t === 'd') {
  return callDmEndpoint(roomId);
}
const channel = await findChannelByIdOrName({ params: { roomId } });
Defensive patterns

Strategy: validation

Validate before calling

// Resolve and classify the room before choosing the endpoint family
async function resolveRoomEndpoint(roomIdOrName) {
  const room = roomIdOrName._id
    ? await Rooms.findOneById(roomIdOrName._id)
    : await Rooms.findOneByName(roomIdOrName.name);
  if (!room) throw new Error('Room not found');
  if (room.t !== 'c' && room.t !== 'l') {
    return { family: room.t === 'p' ? 'groups' : room.t === 'd' ? 'im' : null, room };
  }
  return { family: 'channels', room };
}

Type guard

function isChannelLike(room) {
  return Boolean(room) && (room.t === 'c' || room.t === 'l');
}

Try / catch

try {
  return await api.channels.info({ roomId });
} catch (e) {
  if (e.error === 'error-room-not-found') {
    // Try the groups or im endpoints instead based on room type
    const room = await Rooms.findOneById(roomId);
    if (room?.t === 'p') return await api.groups.info({ roomId });
    throw e;
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling a channels.* endpoint with a roomId/roomName that resolves to a room of type 'p' (private group) or 'd' (direct message), or that does not exist at all. Empty/blank roomId or roomName also yields no match.

Common situations: Using a groups.* identifier against a channels.* endpoint; typos in roomName; case sensitivity on room names; passing an _id that belongs to a team-private room.

Related errors


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