{"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/2f18297792c973da326be7253f497d239ea6f2b0/apps/meteor/client/lib/chats/data.ts#L269-L305","documentation":"getDiscussionByID() throws 'Discussion not found' when Rooms.state.find fails to locate a room with _id === drid that also has a truthy prid (parent room id) — the two conditions that define a discussion record in the local store. It is the strict variant of findDiscussionByID and has no server fallback.","triggerScenarios":"Calling getDiscussionByID with a drid that points to a regular (non-discussion) room, a discussion room not yet synced into the Rooms store (just created, subscription pending), or an invalid id.","commonSituations":"Clicking a 'discussion created' system message immediately after creation before the new room syncs; passing a channel rid where a discussion drid was expected; cache cleared mid-session.","solutions":["Use findDiscussionByID and treat undefined as 'not available yet'.","Ensure the discussion room has been synced (open it or await subscription load) before the strict call.","Validate that the id you pass is the drid from the message's d field, not the parent channel id."],"exampleFix":"// before\nconst discussion = await chat.getDiscussionByID(drid);\n\n// after\nconst discussion = await chat.findDiscussionByID(drid);\nif (!discussion) return; // not synced yet, or drid is not a discussion","handlingStrategy":"validation","validationCode":"const discussion = await chat.findDiscussionByID(drid);\nif (!discussion) return; // not synced yet, or drid is not a discussion","typeGuard":"const isDiscussionRoom = (room: IRoom | undefined): room is IRoom & { prid: string } =>\n  Boolean(room?.prid);","tryCatchPattern":null,"preventionTips":["Confirm drid comes from a discussion message's d field, not the parent channel id.","Give newly created discussions a moment to sync (or open them) before strict lookups.","Use findDiscussionByID where 'not yet available' is a normal state."],"tags":["discussions","rooms","cache"],"backgroundTag":"discussion-not-found","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"}