{"record":{"id":"6b7c07c679762993","repo":"RocketChat/Rocket.Chat","slug":"error-user-not-found-6b7c07","errorCode":null,"errorMessage":"error-user-not-found","messagePattern":"error-user-not-found","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/api/v1/push.ts","lineNumber":306,"sourceCode":"\nconst pushGetInfoEndpoints = API.v1\n\t.get(\n\t\t'push.get',\n\t\t{\n\t\t\tauthRequired: true,\n\t\t\tquery: isPushGetProps,\n\t\t\tresponse: {\n\t\t\t\t200: pushGetResponseSchema,\n\t\t\t\t400: validateBadRequestErrorResponse,\n\t\t\t\t401: validateUnauthorizedErrorResponse,\n\t\t\t},\n\t\t},\n\t\tasync function action() {\n\t\t\tconst { id } = this.queryParams;\n\n\t\t\tconst receiver = await Users.findOneById(this.userId);\n\t\t\tif (!receiver) {\n\t\t\t\tthrow new Error('error-user-not-found');\n\t\t\t}\n\n\t\t\tconst message = await Messages.findOneById(id);\n\t\t\tif (!message) {\n\t\t\t\tthrow new Error('error-message-not-found');\n\t\t\t}\n\n\t\t\tconst room = await Rooms.findOneById(message.rid);\n\t\t\tif (!room) {\n\t\t\t\tthrow new Error('error-room-not-found');\n\t\t\t}\n\n\t\t\tif (!(await canAccessRoomAsync(room, receiver))) {\n\t\t\t\tthrow new Error('error-not-allowed');\n\t\t\t}\n\n\t\t\tconst data = await PushNotification.getNotificationForMessageId({ receiver, room, message });\n","sourceCodeStart":288,"sourceCodeEnd":324,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/f9d3ec372bb580fa8d036f94cf03925a478ef768/apps/meteor/server/api/v1/push.ts#L288-L324","documentation":"Thrown as Error('error-user-not-found') in the GET push.* action when Users.findOneById(this.userId) returns null. Identical shape to the transcript user-not-found case: authRequired populated this.userId, but the user document is missing, so subsequent logic that uses the receiver cannot proceed. The next guards (message-not-found, room-not-found) are never reached.","triggerScenarios":"A push-related GET with a valid auth token whose userId was deleted from the users collection; a fixture that authenticates without inserting the user.","commonSituations":"User deleted after the mobile client cached its session; stale token on a restored-from-backup DB; test harness using a fabricated userId.","solutions":["Verify the X-User-Id corresponds to an existing user document.","Force re-login on the client to obtain a token for a live user.","Audit deletion events for the affected userId."],"exampleFix":"null","handlingStrategy":"try-catch","validationCode":"const me = await fetch('/api/v1/v1/me', { headers }).then(r => r.ok ? r.json() : null);\nif (!me) { /* re-login before push calls */ }","typeGuard":"null","tryCatchPattern":"try {\n  await fetch('/api/v1/v1/push...' /* etc */);\n} catch (e) {\n  if (e.error === 'error-user-not-found') { /* clear session, re-authenticate */ }\n  else throw e;\n}","preventionTips":["Validate the session with /me before push operations.","Clear cached tokens when the user is deleted.","Treat error-user-not-found as a session-invalidation signal."],"tags":["push","authentication","user","not-found","stale-token"],"backgroundTag":null,"analyzedSha":"f9d3ec372bb580fa8d036f94cf03925a478ef768","analyzedAt":"2026-08-12T19:07:17.372Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}