{"record":{"id":"efe1daa0e201e0a8","repo":"RocketChat/Rocket.Chat","slug":"error-invalid-contact-efe1da","errorCode":"error-invalid-contact","errorMessage":"error-invalid-contact","messagePattern":"error-invalid-contact","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"apps/meteor/server/lib/omnichannel/Helper.ts","lineNumber":106,"sourceCode":"\t);\n\n\tconst extraRoomInfo = await beforeNewRoom(roomInfo, extraData);\n\tconst { _id, username, token, department: departmentId, status = 'online' } = guest;\n\tconst newRoomAt = new Date();\n\tconst source = extraRoomInfo.source || roomInfo.source;\n\n\tif (settings.get<string>('Livechat_Require_Contact_Verification') === 'always') {\n\t\tawait LivechatContacts.setChannelVerifiedStatus({ visitorId: _id, source }, false);\n\t}\n\n\tconst contactId = await migrateVisitorIfMissingContact(_id, source);\n\tconst contact =\n\t\tcontactId &&\n\t\t(await LivechatContacts.findOneEnabledById<Pick<ILivechatContact, '_id' | 'name' | 'channels' | 'activity'>>(contactId, {\n\t\t\tprojection: { name: 1, channels: 1, activity: 1 },\n\t\t}));\n\tif (!contact) {\n\t\tthrow new Error('error-invalid-contact');\n\t}\n\tconst verified = Boolean(contact.channels.some((channel) => isVerifiedChannelInSource(channel, _id, source)));\n\n\tconst activity = guest.activity || contact.activity;\n\tlogger.debug({\n\t\tmsg: 'Creating livechat room for visitor',\n\t\tvisitor: { _id, username, departmentId, status, activity },\n\t});\n\n\t// TODO: Solve `u` missing issue\n\treturn {\n\t\t_id: rid,\n\t\tmsgs: 0,\n\t\tusersCount: 1,\n\t\tlm: newRoomAt,\n\t\tfname: contact.name,\n\t\tt: 'l' as const,\n\t\tts: newRoomAt,","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/lib/omnichannel/Helper.ts#L88-L124","documentation":"While creating an omnichannel room for a visitor, Helper.ts runs migrateVisitorIfMissingContact and then loads the visitor's LivechatContact by ID with an enabled-only lookup; if no usable contact comes back it throws error-invalid-contact. It means the visitor-to-contact linkage is broken: migration produced no contact id, or the contact exists but is disabled.","triggerScenarios":"The omnichannel contact record was disabled or deleted in the contact management UI while its visitor still starts chats; migrateVisitorIfMissingContact failed during a contact merge; a new channel (WhatsApp/SMS) where contact creation raced with room creation.","commonSituations":"Contacts merged or disabled by supervisors during active conversations; contact collections left inconsistent after a restore or import; multi-channel contact management operations.","solutions":["Inspect the livechat contacts collection for the visitor's contact _id and its disabled flag; re-enable or recreate it","Edit the visitor's contact info in the Omnichannel Contacts panel to re-run contact migration","Check server logs around migrateVisitorIfMissingContact for the underlying failure"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const room = await createRoom(...);\n} catch (err) {\n  if (err instanceof Error && err.message === 'error-invalid-contact') {\n    // re-save the visitor's contact info (re-runs migration) then retry once\n  } else throw err;\n}","preventionTips":["Avoid disabling/deleting contacts that still have active visitors","After contact merges or imports, spot-check that each visitor resolves to an enabled contact","Watch server logs from migrateVisitorIfMissingContact during contact operations"],"tags":["omnichannel","livechat","contact","visitor","rocket-chat"],"backgroundTag":"entity-not-found","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}