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 when the 'roomId' query parameter is missing. The endpoint calls messageSearch(userId, searchText, roomId, ...) at chat.ts:881, so roomId is required to scope the full-text search. Checked at chat.ts:871.
Source
Thrown at apps/meteor/server/api/v1/chat.ts:870
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 f9d3ec372b)
Solutions
- Always include roomId in the query: chat.search?roomId=GENERAL&searchText=hello.
- Resolve the room id from the current channel context before searching.
- Use a dedicated global search API if you need cross-room search.
Example fix
// before GET /api/v1/chat.search?searchText=deploy // after GET /api/v1/chat.search?roomId=GENERAL&searchText=deploy
Defensive patterns
Strategy: validation
Validate before calling
function buildSearchUrl(roomId: string, searchText: string) {
if (!roomId) throw new Error('roomId is required for chat.search');
const u = new URL('/api/v1/chat.search', location.origin);
u.searchParams.set('roomId', roomId);
u.searchParams.set('searchText', searchText);
return u;
} Type guard
const isSearchQuery = (q: unknown): q is { roomId: string; searchText: string } =>
typeof q === 'object' && q !== null &&
typeof (q as any).roomId === 'string' && (q as any).roomId.length > 0; Try / catch
try {
await GET(searchUrl);
} catch (e) {
if ((e as any)?.error === 'error-roomId-param-not-provided') {
// no active room — do not call search until one is selected
}
throw e;
} Prevention
- Remember chat.search is per-room, not global — always scope by roomId.
- Pull roomId from the active channel context.
- Use the exact param name 'roomId', not 'rid'.
When it happens
Trigger: GET /api/v1/chat.search?searchText=hello with no roomId; passing roomId under 'rid'; calling a global search variant that does not exist.
Common situations: Assuming chat.search is workspace-global (it is per-room); SDK that exposes search(text) without a room scope; UI search box that forgot to attach the active room.
Related errors
- error-searchText-param-not-provided
- error-param-required
- error-lastUpdate-param-invalid
- error-room-id-param-not-provided
- error-user-id-param-not-provided
AI-assisted analysis of RocketChat/Rocket.Chat@f9d3ec372b (2026-08-12).
Data as JSON: /api/errors/f5db54efd6cc54e6.
Report an issue: GitHub.