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 (apps/meteor/server/api/v1/chat.ts:874) when searchText is falsy, with error-searchText-param-not-provided. The query schema requires searchText as a string with no minLength, so an empty value (searchText=) passes schema and dies in the handler. An empty search has no semantics, so it is rejected rather than returning everything.

Solutions

  1. Send a non-empty term: GET /api/v1/chat.search?roomId=GENERAL&searchText=deploy.
  2. Suppress the request when input.trim() is empty in the client.
  3. If the intent was listing messages, use chat.syncMessages instead of an empty search.
  4. Treat this error as a no-op result in UI flows (show 'no results') rather than an error banner.

Example fix

// before
if (query !== undefined) search(query); // '' sneaks through

// after
const term = query?.trim();
if (term) search(term);
Defensive patterns

Strategy: validation

Validate before calling

const term = typeof searchText === 'string' ? searchText.trim() : '';
if (!term) return emptyResult(); // skip the request entirely
await rc.get('/api/v1/chat.search', { params: { roomId, searchText: term } });

Type guard

const hasSearchTerm = (p: { searchText?: unknown }): p is { searchText: string } =>
  typeof p.searchText === 'string' && p.searchText.trim().length > 0;

Try / catch

try {
  await rc.get('/api/v1/chat.search', { params: { roomId, searchText } });
} catch (e) {
  if (e?.errorType === 'error-searchText-param-not-provided') return { messages: [] }; // treat as no-op
  else throw e;
}

Prevention

When it happens

Trigger: GET /api/v1/chat.search?roomId=...&searchText= (empty string), or a missing searchText on older servers. Typically a search box submitting before typing, or trim()-ed input forwarded as-is.

Common situations: Form submits on empty input not being suppressed; debounce logic that fires the request with the pre-typing empty value; automated tests parameterizing searchText as an empty string.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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

Appendix: source

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

						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 e4b8178b20)