{"record":{"id":"7566e3bb15d3e7e0","repo":"RocketChat/Rocket.Chat","slug":"discussion-not-found","errorCode":null,"errorMessage":"Discussion not found","messagePattern":"Discussion not found","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/client/lib/chats/data.ts","lineNumber":287,"sourceCode":"\t\t}\n\n\t\treturn room;\n\t};\n\n\tconst isSubscribedToRoom = async (): Promise<boolean> => !!Subscriptions.state.find((record) => record.rid === rid);\n\n\tconst joinRoom = async (): Promise<void> => {\n\t\tawait sdk.rest.post('/v1/rooms.join', { roomId: rid });\n\t};\n\n\tconst findDiscussionByID = async (drid: IRoom['_id']): Promise<IRoom | undefined> =>\n\t\tRooms.state.find((record) => Boolean(record._id === drid && record.prid));\n\n\tconst getDiscussionByID = async (drid: IRoom['_id']): Promise<IRoom> => {\n\t\tconst discussion = await findDiscussionByID(drid);\n\n\t\tif (!discussion) {\n\t\t\tthrow new Error('Discussion not found');\n\t\t}\n\n\t\treturn discussion;\n\t};\n\n\tconst createStrictGetter = <TFind extends (...args: any[]) => Promise<any>>(\n\t\tfind: TFind,\n\t\terrorMessage: string,\n\t): ((...args: Parameters<TFind>) => Promise<Exclude<Awaited<ReturnType<TFind>>, undefined>>) => {\n\t\treturn async (...args) => {\n\t\t\tconst result = await find(...args);\n\n\t\t\tif (!result) {\n\t\t\t\tthrow new Error(errorMessage);\n\t\t\t}\n\n\t\t\treturn result;\n\t\t};","sourceCodeStart":269,"sourceCodeEnd":305,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/f9d3ec372bb580fa8d036f94cf03925a478ef768/apps/meteor/client/lib/chats/data.ts#L269-L305","documentation":"Thrown by getDiscussionByID when findDiscussionByID returns undefined. findDiscussionByID searches the Rooms store for a record whose _id matches the given discussion room ID (drid) AND that has a prid (parent room ID) — i.e., it confirms the ID refers to a discussion thread spawned from a parent channel/group. If no such room exists in the local cache, it throws.","triggerScenarios":"The discussion room ID does not exist in the Rooms store. The room exists but is not a discussion (no prid field). The discussion was deleted. The discussion data has not been loaded yet (store not hydrated).","commonSituations":"Navigating to a discussion from a stale link. Discussion was archived by an admin. Client started fresh and discussions list hasn't synced. Incorrect drid passed (typo or wrong reference).","solutions":["Use findDiscussionByID() (returns undefined) instead of getDiscussionByID and handle the absence.","Verify the drid corresponds to a room with a prid before calling — check the Rooms store for the prid field.","Fetch the discussion room data from the server if not in cache, then retry.","Catch the error and show a 'discussion not available' message to the user."],"exampleFix":"// before\nconst discussion = await getDiscussionByID(drid);\n// after\nconst discussion = await findDiscussionByID(drid);\nif (!discussion) {\n  // fetch from server or show fallback\n  return;\n}","handlingStrategy":"validation","validationCode":"const discussion = await findDiscussionByID(drid);\nif (!discussion) {\n  // discussion not in cache, fetch or show fallback\n  return;\n}\n// proceed with discussion","typeGuard":"const isDiscussion = (room: IRoom | undefined): room is IRoom =>\n  Boolean(room && room.prid);","tryCatchPattern":"try {\n  const discussion = await getDiscussionByID(drid);\n} catch (e) {\n  if (e instanceof Error && e.message === 'Discussion not found') {\n    showDiscussionUnavailable();\n    return;\n  }\n  throw e;\n}","preventionTips":["Use findDiscussionByID and check for the prid field before calling the strict getter.","Ensure discussion metadata is loaded when navigating from a parent room.","Handle deleted/archived discussions gracefully in the UI."],"tags":["cache","discussion","client-store","room-data"],"backgroundTag":null,"analyzedSha":"f9d3ec372bb580fa8d036f94cf03925a478ef768","analyzedAt":"2026-08-12T19:07:17.372Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}