RocketChat/Rocket.Chat · error · Meteor.Error

error-roomId-param-not-provided

error-roomId-param-not-provided

Error message

The required "roomId" query param is missing.

What it means

Thrown by GET chat.search (apps/meteor/server/api/v1/chat.ts:870) when the roomId query param is falsy, with error-roomId-param-not-provided. The query schema requires roomId as a string but sets no minLength, so an empty roomId= slips past validation and hits this guard. Search is always scoped to one room in Rocket.Chat, hence the hard requirement.

Solutions

  1. Scope the search to a room the user can access: GET /api/v1/chat.search?roomId=GENERAL&searchText=hello.
  2. Disable/guard the search action until a room is selected in your client.
  3. If you need message ids for a workspace-wide search, look at the search REST endpoints under imap/search tooling or use the WebRTC/other indexes - chat.search is room-scoped by design.
  4. Resolve roomId from room name first via GET /api/v1/rooms.info?roomName=... when you only have the channel name.

Example fix

// before
rc.get('/api/v1/chat.search', { params: { searchText } }); // no roomId

// after
rc.get('/api/v1/chat.search', { params: { roomId: currentRoomId, searchText } });
Defensive patterns

Strategy: validation

Validate before calling

if (typeof roomId !== 'string' || roomId.trim() === '') throw new Error('roomId is required for chat.search');
await rc.get('/api/v1/chat.search', { params: { roomId, searchText } });

Type guard

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

Try / catch

try {
  await rc.get('/api/v1/chat.search', { params: { roomId, searchText } });
} catch (e) {
  if (e?.errorType === 'error-roomId-param-not-provided') disableSearchUntilRoomSelected();
  else throw e;
}

Prevention

When it happens

Trigger: GET /api/v1/chat.search?roomId=&searchText=foo (empty roomId), or on builds predating query validation a request missing roomId entirely. Also global-search attempts: there is no workspace-wide mode on this endpoint, so omitting roomId to 'search everywhere' fails here.

Common situations: Search boxes that assume server-wide search like Slack's; blank room selection in the UI when the user searches before opening a channel; room id variables unset during navigation to a deep-linked search page.

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/f5db54efd6cc54e6. Report an issue: GitHub.

Appendix: source

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

				200: ajv.compile<{ messages: IMessage[] }>({
					type: 'object',
					properties: {
						messages: { type: 'array', items: { $ref: '#/components/schemas/IMessage' } },
						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),
			});

View on GitHub (pinned to e4b8178b20)