{"record":{"id":"258b70f58f8864c9","repo":"RocketChat/Rocket.Chat","slug":"invalid-visitor-cannot-create","errorCode":null,"errorMessage":"Invalid visitor, cannot create","messagePattern":"Invalid visitor, cannot create","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/app/apps/server/bridges/livechat.ts","lineNumber":226,"sourceCode":"\n\t\tconst registerData = {\n\t\t\tdepartment: visitor.department,\n\t\t\tusername: visitor.username,\n\t\t\tname: visitor.name,\n\t\t\ttoken: visitor.token,\n\t\t\temail: '',\n\t\t\tid: visitor.id,\n\t\t\t...(visitor.phone?.length && { phone: { number: visitor.phone[0].phoneNumber } }),\n\t\t\t...(visitor.visitorEmails?.length && { email: visitor.visitorEmails[0].address }),\n\t\t};\n\n\t\tconst livechatVisitor = await registerGuest(registerData, {\n\t\t\tshouldConsiderIdleAgent: settings.get<boolean>('Livechat_enabled_when_agent_idle'),\n\t\t\tshouldConsiderOfflineAgent: settings.get<boolean>('Livechat_accept_chats_with_no_agents'),\n\t\t});\n\n\t\tif (!livechatVisitor) {\n\t\t\tthrow new Error('Invalid visitor, cannot create');\n\t\t}\n\n\t\treturn livechatVisitor._id;\n\t}\n\n\tprotected async createAndReturnVisitor(visitor: IVisitor, appId: string): Promise<IVisitor | undefined> {\n\t\tthis.orch.debugLog(`The App ${appId} is creating a livechat visitor.`);\n\n\t\t// Add appId to each externalId entry\n\t\tconst externalIds = visitor.externalIds?.map((entry) => ({ ...entry, appId }));\n\n\t\tconst registerData = {\n\t\t\tdepartment: visitor.department,\n\t\t\tusername: visitor.username,\n\t\t\tname: visitor.name,\n\t\t\ttoken: visitor.token,\n\t\t\temail: '',\n\t\t\tid: visitor.id,","sourceCodeStart":208,"sourceCodeEnd":244,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/2a7de457074cbb4d4373fbd9a4e5bea292c9c764/apps/meteor/app/apps/server/bridges/livechat.ts#L208-L244","documentation":"Error \"Invalid visitor, cannot create\" thrown in RocketChat/Rocket.Chat.","triggerScenarios":"Thrown at apps/meteor/app/apps/server/bridges/livechat.ts:226 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the visitor data passed to createVisitor is complete and valid so registerGuest returns a visitor record.","Check livechat settings (e.g. Livechat_enabled) and the registerGuest result for why visitor creation failed."],"exampleFix":"Validate the visitor object before creating: if (!visitor || !visitor.username) { throw new Error('Invalid visitor, cannot create'); }","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2a7de457074cbb4d4373fbd9a4e5bea292c9c764","analyzedAt":"2026-08-18T15:26:39.429Z","contentChangedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}