{"record":{"id":"1a847ab017188de6","repo":"RocketChat/Rocket.Chat","slug":"error-invalid-params","errorCode":"error-invalid-params","errorMessage":"error-invalid-params","messagePattern":"error-invalid-params","errorType":"error_code","errorClass":"Meteor.Error","httpStatus":400,"severity":"error","filePath":"apps/meteor/server/api/v1/omnichannel/contact.ts","lineNumber":93,"sourceCode":"\t},\n\t{\n\t\tasync get() {\n\t\t\tcheck(this.queryParams, {\n\t\t\t\temail: Match.Maybe(String),\n\t\t\t\tphone: Match.Maybe(String),\n\t\t\t\tcustom: Match.Maybe(String),\n\t\t\t});\n\t\t\tconst { email, phone, custom } = this.queryParams;\n\n\t\t\tlet customCF: { [k: string]: string } = {};\n\t\t\ttry {\n\t\t\t\tcustomCF = custom && JSON.parse(custom);\n\t\t\t} catch (e) {\n\t\t\t\tthrow new Meteor.Error('error-invalid-params-custom');\n\t\t\t}\n\n\t\t\tif (!email && !phone && !Object.keys(customCF).length) {\n\t\t\t\tthrow new Meteor.Error('error-invalid-params');\n\t\t\t}\n\n\t\t\tconst foundCF = await (async () => {\n\t\t\t\tif (!custom) {\n\t\t\t\t\treturn {};\n\t\t\t\t}\n\n\t\t\t\tconst cfIds = Object.keys(customCF);\n\n\t\t\t\tconst customFields = await LivechatCustomField.findMatchingCustomFieldsByIds(cfIds, 'visitor', true, {\n\t\t\t\t\tprojection: { _id: 1 },\n\t\t\t\t}).toArray();\n\n\t\t\t\treturn Object.fromEntries(customFields.map(({ _id }) => [`livechatData.${_id}`, new RegExp(escapeRegExp(customCF[_id]), 'i')]));\n\t\t\t})();\n\n\t\t\tconst contact = await LivechatVisitors.findOneByEmailAndPhoneAndCustomField(email, phone, foundCF);\n\t\t\treturn API.v1.success({ contact });","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/api/v1/omnichannel/contact.ts#L75-L111","documentation":"GET /api/v1/livechat/contact requires at least one lookup criterion: email, phone, or a non-empty parsed custom object. When all are absent (or custom parses to {}), the endpoint throws Meteor.Error 'error-invalid-params'.","triggerScenarios":"Calling livechat/contact with no query params; passing custom={} (empty JSON object); passing custom as an empty string; passing only unrelated params like count/offset.","commonSituations":"Client code branching forgets to attach a criterion; empty search box submitted straight to the API; integrations probing the endpoint for health checks without params.","solutions":["Always include at least one of ?email=..., ?phone=..., or a non-empty ?custom={\"field\":\"value\"}.","Validate before the call: reject empty searches in the UI instead of hitting the API.","If you need to browse contacts without a criterion, use an authenticated visitors listing/search endpoint instead of livechat/contact."],"exampleFix":"// before\nfetch('/api/v1/livechat/contact'); // no criterion -> error-invalid-params\n\n// after\nconst qs = new URLSearchParams();\nif (email) qs.set('email', email);\nif (phone) qs.set('phone', phone);\nif (Object.keys(custom).length) qs.set('custom', JSON.stringify(custom));\nif (![...qs.keys()].length) throw new Error('Provide email, phone or custom');\nfetch(`/api/v1/livechat/contact?${qs}`);","handlingStrategy":"validation","validationCode":"function hasContactCriterion(p: { email?: string; phone?: string; custom?: Record<string, string> }): boolean {\n  return Boolean(p.email || p.phone || (p.custom && Object.keys(p.custom).length > 0));\n}\nif (!hasContactCriterion(params)) throw new RangeError('livechat/contact needs email, phone or non-empty custom');","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Disable the search action until the user entered at least one criterion.","Unit-test client code paths that can produce an empty query.","Treat empty custom={} as no criterion, because the server does."],"tags":["omnichannel","contact","params","rest-api"],"backgroundTag":"missing-required-argument","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","contentChangedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}