RocketChat/Rocket.Chat · error · Error
Discussion not found
Error message
Discussion not found
What it means
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.
Source
Thrown at apps/meteor/client/lib/chats/data.ts:287
}
return room;
};
const isSubscribedToRoom = async (): Promise<boolean> => !!Subscriptions.state.find((record) => record.rid === rid);
const joinRoom = async (): Promise<void> => {
await sdk.rest.post('/v1/rooms.join', { roomId: rid });
};
const findDiscussionByID = async (drid: IRoom['_id']): Promise<IRoom | undefined> =>
Rooms.state.find((record) => Boolean(record._id === drid && record.prid));
const getDiscussionByID = async (drid: IRoom['_id']): Promise<IRoom> => {
const discussion = await findDiscussionByID(drid);
if (!discussion) {
throw new Error('Discussion not found');
}
return discussion;
};
const createStrictGetter = <TFind extends (...args: any[]) => Promise<any>>(
find: TFind,
errorMessage: string,
): ((...args: Parameters<TFind>) => Promise<Exclude<Awaited<ReturnType<TFind>>, undefined>>) => {
return async (...args) => {
const result = await find(...args);
if (!result) {
throw new Error(errorMessage);
}
return result;
};View on GitHub (pinned to f9d3ec372b)
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.
Example fix
// before
const discussion = await getDiscussionByID(drid);
// after
const discussion = await findDiscussionByID(drid);
if (!discussion) {
// fetch from server or show fallback
return;
} Defensive patterns
Strategy: validation
Validate before calling
const discussion = await findDiscussionByID(drid);
if (!discussion) {
// discussion not in cache, fetch or show fallback
return;
}
// proceed with discussion Type guard
const isDiscussion = (room: IRoom | undefined): room is IRoom => Boolean(room && room.prid);
Try / catch
try {
const discussion = await getDiscussionByID(drid);
} catch (e) {
if (e instanceof Error && e.message === 'Discussion not found') {
showDiscussionUnavailable();
return;
}
throw e;
} Prevention
- 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.
When it happens
Trigger: 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).
Common situations: 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).
Related errors
- Room not found
- Subscription not found
- room-not-found
- error-pinning-message
- There must be a parent room to create a discussion.
AI-assisted analysis of RocketChat/Rocket.Chat@f9d3ec372b (2026-08-12).
Data as JSON: /api/errors/7566e3bb15d3e7e0.
Report an issue: GitHub.