{"record":{"id":"9173bfa0cbb4b9bc","repo":"RocketChat/Rocket.Chat","slug":"error-invalid-email-9173bf","errorCode":"error-invalid-email","errorMessage":"Invalid email ${email}","messagePattern":"Invalid email (.+?)","errorType":"exception","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/lib/omnichannel/Helper.ts","lineNumber":958,"sourceCode":"\t\t\tagentsId: agentsAdded,\n\t\t});\n\t}\n\n\tif (agentsUpdated.length > 0) {\n\t\tvoid notifyOnLivechatDepartmentAgentChangedByAgentsAndDepartmentId(agentsUpdated, departmentId);\n\t}\n\n\tif (agentsRemoved.length > 0 || agentsAdded.length > 0) {\n\t\tconst numAgents = await LivechatDepartmentAgents.countByDepartmentId(departmentId);\n\t\tawait LivechatDepartment.updateNumAgentsById(departmentId, numAgents);\n\t}\n\n\treturn true;\n};\n\nexport const validateEmail = (email: string) => {\n\tif (!validatorFunc(email)) {\n\t\tthrow new Meteor.Error('error-invalid-email', `Invalid email ${email}`, {\n\t\t\tfunction: 'Livechat.validateEmail',\n\t\t\temail,\n\t\t});\n\t}\n\treturn true;\n};\n","sourceCodeStart":940,"sourceCodeEnd":965,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/lib/omnichannel/Helper.ts#L940-L965","documentation":"Livechat.validateEmail delegates to validateEmail from @rocket.chat/tools and wraps failure in Meteor.Error('error-invalid-email', 'Invalid email ${email}'), echoing the offending value and function name in the details. It is used to validate email channel addresses when saving omnichannel visitor/contact data.","triggerScenarios":"Passing 'nope', 'a@b' (no TLD per the validator), strings with spaces, or empty/undefined-ish values into livechat visitor email fields (visitor registration API, contact email channels).","commonSituations":"Channel integrations (SMS/WhatsApp) mapping phone numbers into email fields; forms without client-side validation; seed scripts using placeholder values like 'test'.","solutions":["Send a fully qualified address (user@domain.tld) for visitor email channels","Pre-validate with validateEmail from @rocket.chat/tools before calling the API","For non-email channels, map identifiers to the matching channel type instead of email"],"exampleFix":"// before\nvisitor.emails = [phone]; // phone number stuffed into email field\n\n// after\nimport { validateEmail } from '@rocket.chat/tools';\nif (email && !validateEmail(email)) throw new Meteor.Error('error-invalid-email', `Invalid email ${email}`);\nvisitor.emails = [email];","handlingStrategy":"validation","validationCode":"import { validateEmail } from '@rocket.chat/tools';\nif (!validateEmail(email)) {\n  throw new Meteor.Error('error-invalid-email', `Invalid email ${email}`, { email });\n}","typeGuard":null,"tryCatchPattern":"try {\n  Livechat.validateEmail(email);\n} catch (err) {\n  if (err instanceof Meteor.Error && err.error === 'error-invalid-email') {\n    // err.details.email holds the offending value; fix the input\n  } else throw err;\n}","preventionTips":["Validate email fields client-side before submitting visitor/contact forms","Map phone/SMS identifiers to their own channel type, never into email fields","Reject placeholder values like 'test' in seed and import scripts"],"tags":["omnichannel","livechat","email","validation","rocket-chat"],"backgroundTag":"invalid-email-address","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}