{"record":{"id":"730cc9f3c630e9cb","repo":"RocketChat/Rocket.Chat","slug":"error-subscription-not-found","errorCode":"error-subscription-not-found","errorMessage":"Subscription not found","messagePattern":"Subscription not found","errorType":"exception","errorClass":"Meteor.Error","httpStatus":400,"severity":"error","filePath":"apps/meteor/server/lib/e2e/functions/handleSuggestedGroupKey.ts","lineNumber":18,"sourceCode":"import { Rooms, Subscriptions } from '@rocket.chat/models';\nimport { Meteor } from 'meteor/meteor';\n\nimport { notifyOnSubscriptionChangedById, notifyOnRoomChangedById } from '../../notifyListener';\n\nexport async function handleSuggestedGroupKey(\n\thandle: 'accept' | 'reject',\n\trid: string,\n\tuserId: string | null,\n\tmethod: string,\n): Promise<void> {\n\tif (!userId) {\n\t\tthrow new Meteor.Error('error-invalid-user', 'Invalid user', { method });\n\t}\n\n\tconst sub = await Subscriptions.findOneByRoomIdAndUserId(rid, userId);\n\tif (!sub) {\n\t\tthrow new Meteor.Error('error-subscription-not-found', 'Subscription not found', { method });\n\t}\n\n\tconst suggestedKey = String(sub.E2ESuggestedKey ?? '').trim();\n\tif (!suggestedKey) {\n\t\tthrow new Meteor.Error('error-no-suggested-key-available', 'No suggested key available', { method });\n\t}\n\n\tif (handle === 'accept') {\n\t\t// A merging process can happen here, but we're not doing that for now\n\t\t// If a user already has oldRoomKeys, we will ignore the suggested ones\n\t\tconst oldKeys = sub.oldRoomKeys ? undefined : sub.suggestedOldRoomKeys;\n\t\tawait Subscriptions.setGroupE2EKeyAndOldRoomKeys(sub._id, suggestedKey, oldKeys);\n\t\tconst { modifiedCount } = await Rooms.removeUsersFromE2EEQueueByRoomId(sub.rid, [userId]);\n\t\tif (modifiedCount) {\n\t\t\tvoid notifyOnRoomChangedById(sub.rid);\n\t\t}\n\t}\n","sourceCodeStart":1,"sourceCodeEnd":36,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/lib/e2e/functions/handleSuggestedGroupKey.ts#L1-L36","documentation":"Thrown when Subscriptions.findOneByRoomIdAndUserId(rid, userId) returns null: the acting user has no subscription document for that room, so there is no E2E suggested-key context to accept or reject. This check runs immediately after the user validation.","triggerScenarios":"Accepting or rejecting a suggested group key for a room the user never joined, was removed from, or whose subscription was deleted — or with a mismatched/typo'd rid.","commonSituations":"Stale client UI still listing a room the user already left; the user was removed while the key dialog was open; room id copied between environments.","solutions":["Reload the room list and confirm the user is still a member of the room","If membership is expected, rejoin the room so a subscription exists, then retry the key action"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const sub = await Subscriptions.findOneByRoomIdAndUserId(rid, userId);\nif (!sub) {\n  // user is not in the room: hide the accept/reject suggested-key action\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Refresh the subscription cache after room leave/remove events","Check membership before rendering E2E key prompts"],"tags":["e2e","subscription","room"],"backgroundTag":"subscription-not-found","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}