RocketChat/Rocket.Chat · warning · RoomNotFoundError
room-not-found
room-not-found
Error message
Room not found
What it means
Thrown as RoomNotFoundError ('room-not-found') when either reference or type is falsy at the point the queryFn needs them to call the getRoomByTypeAndName method. These come from route params; a missing value means the URL/route is malformed for room resolution.
Source
Thrown at apps/meteor/client/views/room/hooks/useOpenRoom.ts:74
// we need to add uid and username here because `user` is not loaded all at once (see UserProvider -> Meteor.user())
queryKey: roomsQueryKeys.roomReference(reference, type, user?._id, user?.username),
// Render immediately from local cache when we already know the rid; queryFn still runs in
// the background to revalidate permissions / fetch fresh room fields.
placeholderData: tryCacheShortcut,
queryFn: async (): Promise<{ rid: IRoom['_id'] }> => {
const cached = tryCacheShortcut();
if (cached) {
LegacyRoomManager.open({ typeName: type + reference, rid: cached.rid });
return cached;
}
if ((user && !user.username) || (!user && !allowAnonymousRead)) {
throw new NotAuthorizedError();
}
if (!reference || !type) {
throw new RoomNotFoundError(undefined, { type, reference });
}
let roomData: IRoom;
try {
roomData = await getRoomByTypeAndName(type, reference);
} catch (error) {
const errorCode = error && typeof error === 'object' && 'error' in error ? error.error : undefined;
// "No permission" means the room exists but the user can't see it — surface the
// not-found/no-access screen rather than retrying it as a transient failure.
if (errorCode === 'error-no-permission') {
throw new RoomNotFoundError(undefined, { type, reference });
}
if (errorCode !== 'error-invalid-room') {
throw error;
}
View on GitHub (pinned to f9d3ec372b)
Solutions
- Validate the route params at the route component boundary and redirect to /home when type/reference are missing.
- Fix the link/redirect source to always include both type and reference.
- Render a 'room not found' page instead of letting the query run with empty params.
Example fix
// before
if (!reference || !type) {
throw new RoomNotFoundError(undefined, { type, reference });
}
// after: guard at component level
if (!reference || !type) {
return <RoomNotFoundScreen />;
} Defensive patterns
Strategy: validation
Validate before calling
// Guard at the route component boundary.
if (!type || !reference) {
router.navigate('/home', { replace: true });
return;
} Type guard
const hasRoomRouteParams = (p: { type?: unknown; reference?: unknown }): p is { type: RoomType; reference: string } =>
typeof p.type === 'string' && p.type.length > 0 &&
typeof p.reference === 'string' && p.reference.length > 0; Prevention
- Validate route params before invoking useOpenRoom.
- Construct room deep links with both type and reference always present.
- Redirect malformed URLs to /home rather than running the query.
When it happens
Trigger: Navigating to a room route with an empty type or reference segment (e.g. /group// or /channel/); route param parsing returned undefined due to a malformed deep link; programmatic navigation that omitted required params.
Common situations: Stale/bookmarked URL with a missing segment; custom integration building a room URL incorrectly; a redirect that strips the reference.
Related errors
- There must be a parent room to create a discussion.
- User not subscribed to room
- roomId was not provided.
- Room not found
- not-authorized
AI-assisted analysis of RocketChat/Rocket.Chat@f9d3ec372b (2026-08-12).
Data as JSON: /api/errors/f29eea0c33f6a80c.
Report an issue: GitHub.