{"record":{"id":"29fd49cc4e8513dd","repo":"RocketChat/Rocket.Chat","slug":"error-invalid-user-29fd49","errorCode":"error-invalid-user","errorMessage":"Invalid user","messagePattern":"Invalid user","errorType":"exception","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/meteor-methods/platform/requestSubscriptionKeys.ts","lineNumber":42,"sourceCode":"\t\t},\n\t\t_id: {\n\t\t\t$in: roomIds,\n\t\t},\n\t};\n\n\tconst rooms = Rooms.find(query);\n\tawait rooms.forEach((room) => {\n\t\tvoid api.broadcast('notify.e2e.keyRequest', room._id, room.e2eKeyId);\n\t});\n};\n\nMeteor.methods<ServerMethods>({\n\tasync 'e2e.requestSubscriptionKeys'() {\n\t\tmethodDeprecationLogger.method('e2e.requestSubscriptionKeys', '9.0.0', '/v1/e2e.requestSubscriptionKeys');\n\n\t\tconst userId = Meteor.userId();\n\t\tif (!userId) {\n\t\t\tthrow new Meteor.Error('error-invalid-user', 'Invalid user', {\n\t\t\t\tmethod: 'requestSubscriptionKeys',\n\t\t\t});\n\t\t}\n\n\t\tawait requestSubscriptionKeysMethod(userId);\n\n\t\treturn true;\n\t},\n});\n","sourceCodeStart":24,"sourceCodeEnd":52,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/meteor-methods/platform/requestSubscriptionKeys.ts#L24-L52","documentation":"The deprecated `e2e.requestSubscriptionKeys` method (replacement: `/v1/e2e.requestSubscriptionKeys`) re-broadcasts `notify.e2e.keyRequest` for the user's encrypted rooms; it throws `error-invalid-user` when `Meteor.userId()` is null. Re-requesting E2E room keys only makes sense for an authenticated session.","triggerScenarios":"Calling `Meteor.call('e2e.requestSubscriptionKeys')` from a logged-out connection — typically a client E2E retry queue flushing after logout, or a startup race before login.","commonSituations":"Logout while encrypted-room key requests are still pending; client retry timers surviving session teardown; scripts forgetting to authenticate.","solutions":["Authenticate before invoking the method","Cancel/flush pending E2E retry queues on logout so they cannot fire without a session","Migrate to `/v1/e2e.requestSubscriptionKeys`"],"exampleFix":"// before\nretryQueue.add(() => Meteor.call('e2e.requestSubscriptionKeys'));\n// after\nretryQueue.add(() => {\n  if (!Meteor.userId()) return; // session gone, skip\n  Meteor.call('e2e.requestSubscriptionKeys');\n});","handlingStrategy":"validation","validationCode":"if (!Meteor.userId()) {\n  return; // session gone, drop the retry\n}\nMeteor.call('e2e.requestSubscriptionKeys', cb);","typeGuard":null,"tryCatchPattern":"try {\n  await Meteor.callAsync('e2e.requestSubscriptionKeys');\n} catch (e) {\n  if (e instanceof Meteor.Error && e.error === 'error-invalid-user') {\n    // stop the retry queue; re-run after login\n  }\n}","preventionTips":["Flush E2E retry queues on logout","Only enqueue key-request retries while a session exists","Migrate to /v1/e2e.requestSubscriptionKeys"],"tags":["e2ee","authentication","deprecated","meteor-method"],"backgroundTag":"user-not-authenticated","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}