{"record":{"id":"f29eea0c33f6a80c","repo":"RocketChat/Rocket.Chat","slug":"room-not-found-f29eea","errorCode":"room-not-found","errorMessage":"Room not found","messagePattern":"Room not found","errorType":"error_code","errorClass":"RoomNotFoundError","httpStatus":null,"severity":"error","filePath":"apps/meteor/client/views/room/hooks/useOpenRoom.ts","lineNumber":74,"sourceCode":"\t\t// we need to add uid and username here because `user` is not loaded all at once (see UserProvider -> Meteor.user())\n\t\tqueryKey: roomsQueryKeys.roomReference(reference, type, user?._id, user?.username),\n\n\t\t// Render immediately from local cache when we already know the rid; queryFn still runs in\n\t\t// the background to revalidate permissions / fetch fresh room fields.\n\t\tplaceholderData: tryCacheShortcut,\n\n\t\tqueryFn: async (): Promise<{ rid: IRoom['_id'] }> => {\n\t\t\tconst cached = tryCacheShortcut();\n\t\t\tif (cached) {\n\t\t\t\tLegacyRoomManager.open({ typeName: type + reference, rid: cached.rid });\n\t\t\t\treturn cached;\n\t\t\t}\n\t\t\tif ((user && !user.username) || (!user && !allowAnonymousRead)) {\n\t\t\t\tthrow new NotAuthorizedError();\n\t\t\t}\n\n\t\t\tif (!reference || !type) {\n\t\t\t\tthrow new RoomNotFoundError(undefined, { type, reference });\n\t\t\t}\n\n\t\t\tlet roomData: IRoom;\n\t\t\ttry {\n\t\t\t\troomData = await getRoomByTypeAndName(type, reference);\n\t\t\t} catch (error) {\n\t\t\t\tconst errorCode = error && typeof error === 'object' && 'error' in error ? error.error : undefined;\n\n\t\t\t\t// \"No permission\" means the room exists but the user can't see it — surface the\n\t\t\t\t// not-found/no-access screen rather than retrying it as a transient failure.\n\t\t\t\tif (errorCode === 'error-no-permission') {\n\t\t\t\t\tthrow new RoomNotFoundError(undefined, { type, reference });\n\t\t\t\t}\n\n\t\t\t\tif (errorCode !== 'error-invalid-room') {\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/2f18297792c973da326be7253f497d239ea6f2b0/apps/meteor/client/views/room/hooks/useOpenRoom.ts#L56-L92","documentation":"RoomNotFoundError (`room-not-found`) thrown by useOpenRoom's queryFn when the route lacks the room type or reference segment, i.e. the URL cannot identify any room. It is a client-side precondition failure raised before any network request is made.","triggerScenarios":"Navigating to a room route whose params are empty — e.g. /channel/ (no name), a programmatic router.push({ type, reference }) with reference undefined, or a broken deep link that lost its path segment.","commonSituations":"A route template built with an undefined variable; trailing-slash or rewritten URLs stripping the name; unit tests mounting the room context without providing route params.","solutions":["Inspect the URL that triggered the navigation and make sure the type and name segments are present and URL-encoded.","Fix the caller that builds the route (router.push/replace) so reference and type can never be undefined.","Add a route guard that redirects malformed room URLs to home instead of mounting the room view."],"exampleFix":"// before\ndirectRoute.push({ rid }); // type/reference missing in some paths\n\n// after\nroomCoordinator.openRouteLink(type, { name: reference }, router.getSearchParameters());","handlingStrategy":"validation","validationCode":"const hasRoomRouteParams = (type?: string, reference?: string): boolean => Boolean(type && reference);","typeGuard":"const isRoomNotFound = (error: unknown): error is RocketChatError<'room-not-found'> =>\n\tBoolean(error && typeof error === 'object' && 'error' in error && (error as { error: string }).error === 'room-not-found');","tryCatchPattern":"try {\n\tawait openRoom(type, reference);\n} catch (error) {\n\tif (isRoomNotFound(error) && (!type || !reference)) {\n\t\tredirect('/home'); // malformed URL, nothing to retry\n\t\treturn;\n\t}\n\tthrow error;\n}","preventionTips":["Never build room URLs from possibly-undefined variables; assert segments first.","Add route preconditions that reject room URLs without a name segment.","URL-encode room names to keep path segments intact."],"tags":["client","routing","validation","room"],"backgroundTag":"missing-route-param","analyzedSha":"2f18297792c973da326be7253f497d239ea6f2b0","analyzedAt":"2026-08-18T15:26:39.429Z","contentChangedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}