RocketChat/Rocket.Chat · error · Meteor.Error

error-invalid-params

error-invalid-params

Error message

error-invalid-params

What it means

Thrown by GET /api/v1/omnichannel/contact.search when none of email, phone, or parsed custom fields are provided. The endpoint requires at least one search criterion — an empty search is rejected before querying the database.

Source

Thrown at apps/meteor/server/api/v1/omnichannel/contact.ts:94

	},
	{
		async get() {
			check(this.queryParams, {
				email: Match.Maybe(String),
				phone: Match.Maybe(String),
				custom: Match.Maybe(String),
			});
			const { email, phone, custom } = this.queryParams;

			let customCF: { [k: string]: string } = {};
			try {
				customCF = custom && JSON.parse(custom);
			} catch (e) {
				throw new Meteor.Error('error-invalid-params-custom');
			}

			if (!email && !phone && !Object.keys(customCF).length) {
				throw new Meteor.Error('error-invalid-params');
			}

			const foundCF = await (async () => {
				if (!custom) {
					return {};
				}

				const cfIds = Object.keys(customCF);

				const customFields = await LivechatCustomField.findMatchingCustomFieldsByIds(cfIds, 'visitor', true, {
					projection: { _id: 1 },
				}).toArray();

				return Object.fromEntries(customFields.map(({ _id }) => [`livechatData.${_id}`, new RegExp(escapeRegExp(customCF[_id]), 'i')]));
			})();

			const contact = await LivechatVisitors.findOneByEmailAndPhoneAndCustomField(email, phone, foundCF);
			return API.v1.success({ contact });

View on GitHub (pinned to f9d3ec372b)

Solutions

  1. Provide at least one of email, phone, or custom as a non-empty query parameter.
  2. Validate on the client side that at least one search criterion is present before making the request.

Example fix

// before: no search criteria
GET /api/v1/omnichannel/contact.search
// after: at least one criterion
GET /api/v1/omnichannel/contact.search?email=guest@example.com
Defensive patterns

Strategy: validation

Validate before calling

// Ensure at least one search criterion is present before calling the API
function validateContactSearchParams({ email, phone, custom }) {
  const hasEmail = email && email.trim().length > 0;
  const hasPhone = phone && phone.trim().length > 0;
  const hasCustom = custom && Object.keys(typeof custom === 'string' ? JSON.parse(custom) : custom).length > 0;
  if (!hasEmail && !hasPhone && !hasCustom) {
    throw new Error('At least one of email, phone, or custom must be provided');
  }
}

Try / catch

try {
  await searchContact(params);
} catch (e) {
  if (e.error === 'error-invalid-params') {
    console.error('At least one search criterion (email, phone, or custom) is required.');
    return;
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling contact.search with no query parameters at all, or with all parameters empty/null/whitespace. The check is: if (!email && !phone && !Object.keys(customCF).length).

Common situations: Client sends a bare request without any filter; all search fields were left blank in the UI form; the query string was stripped by a proxy or middleware.

Related errors


AI-assisted analysis of RocketChat/Rocket.Chat@f9d3ec372b (2026-08-12). Data as JSON: /api/errors/1a847ab017188de6. Report an issue: GitHub.