{"record":{"id":"c9b80c39ba5dd620","repo":"RocketChat/Rocket.Chat","slug":"invalid-visitor-cannot-transfer","errorCode":null,"errorMessage":"Invalid visitor, cannot transfer","messagePattern":"Invalid visitor, cannot transfer","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/app/apps/server/bridges/livechat.ts","lineNumber":262,"sourceCode":"\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\t...(externalIds?.length && { externalIds }),\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\treturn this.orch.getConverters()?.get('visitors').convertVisitor(livechatVisitor);\n\t}\n\n\tprotected async transferVisitor(visitor: IVisitor, transferData: ILivechatTransferData, appId: string): Promise<boolean> {\n\t\tthis.orch.debugLog(`The App ${appId} is transfering a livechat.`);\n\n\t\tif (!visitor) {\n\t\t\tthrow new Error('Invalid visitor, cannot transfer');\n\t\t}\n\n\t\tconst { targetAgent, targetDepartment: departmentId, currentRoom } = transferData;\n\n\t\tconst appUser = await Users.findOneByAppId(appId, {});\n\t\tif (!appUser) {\n\t\t\tthrow new Error('Invalid app user, cannot transfer');\n\t\t}\n\t\tconst { _id, username, name, type } = appUser;\n\t\tconst transferredBy = {\n\t\t\t_id,\n\t\t\tusername,\n\t\t\tname,\n\t\t\ttype,\n\t\t\tuserType: 'user',\n\t\t} as const;\n\n\t\tlet userId;","sourceCodeStart":244,"sourceCodeEnd":280,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/2a7de457074cbb4d4373fbd9a4e5bea292c9c764/apps/meteor/app/apps/server/bridges/livechat.ts#L244-L280","documentation":"Error \"Invalid visitor, cannot transfer\" thrown in RocketChat/Rocket.Chat.","triggerScenarios":"Thrown at apps/meteor/app/apps/server/bridges/livechat.ts:262 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass a valid visitor object to transferVisitor; do not call it with a null or undefined visitor.","Fetch the visitor first and confirm it exists before initiating the transfer."],"exampleFix":"Check the visitor exists before transfer: if (!visitor) { throw new Error('Invalid visitor, cannot transfer'); }","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"}