{"record":{"id":"146c2694fdef9a98","repo":"RocketChat/Rocket.Chat","slug":"error-invalid-user-146c26","errorCode":"error-invalid-user","errorMessage":"error-invalid-user","messagePattern":"error-invalid-user","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"apps/meteor/server/lib/omnichannel/tracking.ts","lineNumber":22,"sourceCode":"import { livechatLogger } from './logger';\nimport { settings } from '../../settings';\n\ntype PageInfo = { title: string; location: { href: string }; change: string };\n\nexport async function savePageHistory(token: string, roomId: string | undefined, pageInfo: PageInfo) {\n\tlivechatLogger.debug({\n\t\tmsg: `Saving page movement history for visitor with token ${token}`,\n\t\tpageInfo,\n\t\troomId,\n\t});\n\n\tif (pageInfo.change !== settings.get<string>('Livechat_history_monitor_type')) {\n\t\treturn;\n\t}\n\tconst user = await Users.findOneById('rocket.cat');\n\n\tif (!user) {\n\t\tthrow new Error('error-invalid-user');\n\t}\n\n\tconst pageTitle = pageInfo.title;\n\tconst pageUrl = pageInfo.location.href;\n\tconst extraData: {\n\t\tnavigation: {\n\t\t\tpage: PageInfo;\n\t\t\ttoken: string;\n\t\t};\n\t\texpireAt?: number;\n\t\t_hidden?: boolean;\n\t} = {\n\t\tnavigation: {\n\t\t\tpage: pageInfo,\n\t\t\ttoken,\n\t\t},\n\t};\n","sourceCodeStart":4,"sourceCodeEnd":40,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/lib/omnichannel/tracking.ts#L4-L40","documentation":"saveNavigationHistory (livechat visitor page tracking) authors its system messages as rocket.cat; it loads Users.findOneById('rocket.cat') and throws Error('error-invalid-user') when the document is missing. Like the transcript fallback, rocket.cat is a guaranteed system account, so its absence means the users collection was damaged (bad restore, migration, or a cleanup script that deleted system users).","triggerScenarios":"A livechat visitor navigates pages with the history monitor active (pageInfo.change equals Livechat_history_monitor_type) on a deployment where the rocket.cat user was deleted — every page-tracking event then fails with this error.","commonSituations":"Same family as other rocket.cat-missing failures: scripts purging users, imports that skipped system accounts, broken migrations between major versions, or manual DB surgery.","solutions":["Verify db.users.findOne({_id: 'rocket.cat'}) and recreate the system user if absent (copy document shape from a clean install of the same version)","Find and fix whatever removes system users (cleanup jobs, LDAP/SCIM filters, import tooling)","Re-test by visiting a livechat widget page with history monitoring enabled and confirming livechat_navigation_history messages are written","Monitor logs for 'error-invalid-user' after the fix to confirm tracking recovered"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"import { Users } from '@rocket.chat/models';\n\nconst cat = await Users.findOneById('rocket.cat');\nif (!cat) {\n  // refuse to process tracking events; alert ops that the system user is missing\n  throw new Error('rocket.cat system user missing — navigation history cannot be recorded');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Blocklist _id 'rocket.cat' in every user-deletion script and import pipeline","Add a post-restore smoke test asserting rocket.cat exists","Alert when livechat navigation history writes start failing — it signals data damage early"],"tags":["omnichannel","visitor-tracking","rocket-cat","system-user","navigation-history"],"backgroundTag":"missing-system-user","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","contentChangedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-09-09T01:17:15.007Z"}