{"record":{"id":"b51c565914ca157c","repo":"RocketChat/Rocket.Chat","slug":"error-invalid-user-b51c56","errorCode":null,"errorMessage":"error-invalid-user","messagePattern":"error-invalid-user","errorType":"exception","errorClass":"Error","httpStatus":400,"severity":"error","filePath":"apps/meteor/server/api/v1/omnichannel/room.ts","lineNumber":412,"sourceCode":");\n\ntype LivechatAnalyticsEndpoints = ExtractRoutesFromAPI<typeof livechatVisitorDepartmentTransfer>;\ndeclare module '@rocket.chat/rest-typings' {\n\t// eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-empty-interface\n\tinterface Endpoints extends LivechatAnalyticsEndpoints {}\n}\n\nAPI.v1.addRoute(\n\t'livechat/room.join',\n\t{ authRequired: true, permissionsRequired: ['view-l-room'], validateParams: isLiveChatRoomJoinProps },\n\t{\n\t\tasync get() {\n\t\t\tconst { roomId } = this.queryParams;\n\n\t\t\tconst { user } = this;\n\n\t\t\tif (!user) {\n\t\t\t\tthrow new Error('error-invalid-user');\n\t\t\t}\n\n\t\t\tconst room = await LivechatRooms.findOneById(roomId);\n\n\t\t\tif (!room) {\n\t\t\t\tthrow new Error('error-invalid-room');\n\t\t\t}\n\n\t\t\tif (!room.open) {\n\t\t\t\tthrow new Error('room-closed');\n\t\t\t}\n\n\t\t\tif (!(await Omnichannel.isWithinMACLimit(room))) {\n\t\t\t\tthrow new Error('error-mac-limit-reached');\n\t\t\t}\n\n\t\t\tif (!(await canAccessRoomAsync(room, user))) {\n\t\t\t\tthrow new Error('error-not-allowed');","sourceCodeStart":394,"sourceCodeEnd":430,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/api/v1/omnichannel/room.ts#L394-L430","documentation":"Thrown by GET /api/v1/livechat/room.join when this.user is falsy. The route is authRequired, so an auth failure normally 401s earlier; reaching this throw means authentication succeeded (userId resolved) but the user document could not be loaded — a server-side inconsistency rather than a normal client mistake.","triggerScenarios":"Authenticated request whose user record is missing/unreadable at lookup time: user deleted between token validation and handler execution, partially-migrated user data, or an auth token referencing a stale user id.","commonSituations":"User deleted/deactivated while its token was still cached in a client; database restores or user-management sync jobs; very rare on healthy installs.","solutions":["Log out and re-authenticate to obtain a fresh token for a valid user","Verify the user still exists and is active (login works) on the same instance","If it reproduces for an existing user, inspect server logs and the users collection — treat as a data-integrity incident"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const me = await (await fetch(`${url}/api/v1/me`, { headers: authHeaders })).json();\nif (!me?._id || !me.username) { await reAuthenticate(); return; }","typeGuard":"function isAuthenticatedUser(u) {\n  return Boolean(u) && typeof u._id === 'string';\n}","tryCatchPattern":"try { await joinRoom(roomId); } catch (e) { if (e.message === 'error-invalid-user') { await reAuthenticate(); return joinRoom(roomId); } throw e; }","preventionTips":["Proactively refresh auth tokens whose user may have been deleted","Treat this error as a signal of server-side data drift — report it, do not loop retries","Drop cached credentials on repeated occurrences"],"tags":["omnichannel","livechat","authentication","user-not-found","rest-api"],"backgroundTag":"auth-user-not-found","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","contentChangedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}