{"record":{"id":"b7d5fd768387d855","repo":"RocketChat/Rocket.Chat","slug":"subscription-not-found","errorCode":null,"errorMessage":"Subscription not found","messagePattern":"Subscription not found","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/client/lib/chats/data.ts","lineNumber":301,"sourceCode":"\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};\n\t};\n\n\tconst findSubscription = async (): Promise<ISubscription | undefined> => {\n\t\treturn Subscriptions.state.find((record) => record.rid === rid);\n\t};\n\n\tconst getSubscription = createStrictGetter(findSubscription, 'Subscription not found');\n\n\tconst findSubscriptionFromMessage = async (message: IMessage): Promise<ISubscription | undefined> => {\n\t\treturn Subscriptions.state.find((record) => record.rid === message.rid);\n\t};\n\n\tconst getSubscriptionFromMessage = createStrictGetter(findSubscriptionFromMessage, 'Subscription not found');\n","sourceCodeStart":283,"sourceCodeEnd":319,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/f9d3ec372bb580fa8d036f94cf03925a478ef768/apps/meteor/client/lib/chats/data.ts#L283-L319","documentation":"Thrown via createStrictGetter, a generic wrapper that calls findSubscription and throws if the result is falsy. findSubscription searches the Subscriptions store for a record whose rid matches the chat context's room ID. If the user has no subscription for this room (meaning they are not a member), the strict getter throws 'Subscription not found'.","triggerScenarios":"The current user is not subscribed to the room (not a member). The Subscriptions store has not finished syncing after login. The subscription was removed (user left/was removed from the room) but the component is still mounted. Accessing a room via a permalink without having joined it.","commonSituations":"Previewing a public room before joining. User was kicked/removed from a room but the UI hasn't updated. Fresh login where the subscriptions sync is still in progress. Direct link to a room the user has never joined.","solutions":["Switch to findSubscription() which returns undefined instead of throwing, and handle non-membership gracefully.","Call joinRoom() before getSubscription() to ensure the user is subscribed.","Check isSubscribedToRoom() (the boolean guard) before calling getSubscription.","Catch the error and show a join-room prompt or redirect the user."],"exampleFix":"// before\nconst sub = await getSubscription();\n// after\nif (!(await isSubscribedToRoom())) {\n  await joinRoom();\n}\nconst sub = await getSubscription();","handlingStrategy":"validation","validationCode":"if (!(await isSubscribedToRoom())) {\n  await joinRoom();\n}\nconst sub = await getSubscription();","typeGuard":"const isSubscribed = async (): Promise<boolean> => {\n  return Boolean(await findSubscription());\n};","tryCatchPattern":"try {\n  const sub = await getSubscription();\n} catch (e) {\n  if (e instanceof Error && e.message === 'Subscription not found') {\n    // prompt user to join the room\n    showJoinPrompt();\n    return;\n  }\n  throw e;\n}","preventionTips":["Call isSubscribedToRoom() or use findSubscription() before the strict getter.","Join the room (joinRoom()) before accessing subscription data.","Wait for the subscriptions sync to complete after login before accessing subscription data."],"tags":["cache","subscription","client-store","room-membership"],"backgroundTag":null,"analyzedSha":"f9d3ec372bb580fa8d036f94cf03925a478ef768","analyzedAt":"2026-08-12T19:07:17.372Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}