RocketChat/Rocket.Chat · error · Meteor.Error

error-searchText-param-not-provided

error-searchText-param-not-provided

Error message

The required "searchText" query param is missing.

What it means

Thrown by GET chat.search when 'searchText' is missing. The endpoint cannot run an empty full-text query against the room; checked at chat.ts:875 right after the roomId guard.

Source

Thrown at apps/meteor/server/api/v1/chat.ts:874

						success: { type: 'boolean', enum: [true] },
					},
					required: ['messages', 'success'],
					additionalProperties: false,
				}),
				400: validateBadRequestErrorResponse,
				401: validateUnauthorizedErrorResponse,
			},
		},
		async function action() {
			const { roomId, searchText } = this.queryParams;
			const { offset, count } = await getPaginationItems(this.queryParams);

			if (!roomId) {
				throw new Meteor.Error('error-roomId-param-not-provided', 'The required "roomId" query param is missing.');
			}

			if (!searchText) {
				throw new Meteor.Error('error-searchText-param-not-provided', 'The required "searchText" query param is missing.');
			}

			const searchResult = await messageSearch(this.userId, searchText, roomId, count, offset);
			if (searchResult === false) {
				return API.v1.failure();
			}
			if (!searchResult.message) {
				return API.v1.failure();
			}
			const result = searchResult.message.docs;

			return API.v1.success({
				messages: await normalizeMessagesForUser(result, this.userId),
			});
		},
	)
	// The difference between `chat.postMessage` and `chat.sendMessage` is that `chat.sendMessage` allows
	// for passing a value for `_id` and the other one doesn't. Also, `chat.sendMessage` only sends it to

View on GitHub (pinned to f9d3ec372b)

Solutions

  1. Include a non-empty searchText: chat.search?roomId=GENERAL&searchText=deploy.
  2. Guard the UI submit button so it is disabled while the query is empty.
  3. Use the documented param name exactly — searchText, not q or query.

Example fix

// before
GET /api/v1/chat.search?roomId=GENERAL&q=deploy
// after
GET /api/v1/chat.search?roomId=GENERAL&searchText=deploy
Defensive patterns

Strategy: validation

Validate before calling

function runSearch(roomId: string, term: string) {
  const t = (term || '').trim();
  if (!t) throw new Error('searchText is required and must be non-empty');
  return GET(`/api/v1/chat.search?roomId=${encodeURIComponent(roomId)}&searchText=${encodeURIComponent(t)}`);
}

Type guard

const hasSearchText = (q: { searchText?: string }): boolean =>
  typeof q.searchText === 'string' && q.searchText.trim().length > 0;

Try / catch

try {
  await GET(searchUrl);
} catch (e) {
  if ((e as any)?.error === 'error-searchText-param-not-provided') {
    // user submitted an empty query — ignore rather than retry
  }
  throw e;
}

Prevention

When it happens

Trigger: GET /api/v1/chat.search?roomId=GENERAL with no searchText; passing the term under 'query'/'q'/'term' instead. Note the endpoint returns API.v1.failure() (not success) when messageSearch itself yields no result, but a missing searchText throws before that.

Common situations: Submitting the search form before the user typed anything; client that clears the term before debounce fires; wrong param name from a generic search helper.

Related errors


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