{"record":{"id":"f5db54efd6cc54e6","repo":"RocketChat/Rocket.Chat","slug":"error-roomid-param-not-provided","errorCode":"error-roomId-param-not-provided","errorMessage":"The required \"roomId\" query param is missing.","messagePattern":"The required \"roomId\" query param is missing\\.","errorType":"exception","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/api/v1/chat.ts","lineNumber":874,"sourceCode":"\t\t\t\t200: ajv.compile<{ messages: IMessage[] }>({\n\t\t\t\t\ttype: 'object',\n\t\t\t\t\tproperties: {\n\t\t\t\t\t\tmessages: { type: 'array', items: { $ref: '#/components/schemas/IMessage' } },\n\t\t\t\t\t\tsuccess: { type: 'boolean', enum: [true] },\n\t\t\t\t\t},\n\t\t\t\t\trequired: ['messages', 'success'],\n\t\t\t\t\tadditionalProperties: false,\n\t\t\t\t}),\n\t\t\t\t400: validateBadRequestErrorResponse,\n\t\t\t\t401: validateUnauthorizedErrorResponse,\n\t\t\t},\n\t\t},\n\t\tasync function action() {\n\t\t\tconst { roomId, searchText } = this.queryParams;\n\t\t\tconst { offset, count } = await getPaginationItems(this.queryParams);\n\n\t\t\tif (!roomId) {\n\t\t\t\tthrow new Meteor.Error('error-roomId-param-not-provided', 'The required \"roomId\" query param is missing.');\n\t\t\t}\n\n\t\t\tif (!searchText) {\n\t\t\t\tthrow new Meteor.Error('error-searchText-param-not-provided', 'The required \"searchText\" query param is missing.');\n\t\t\t}\n\n\t\t\tconst searchResult = await messageSearch(this.userId, searchText, roomId, count, offset);\n\t\t\tif (searchResult === false) {\n\t\t\t\treturn API.v1.failure();\n\t\t\t}\n\t\t\tif (!searchResult.message) {\n\t\t\t\treturn API.v1.failure();\n\t\t\t}\n\t\t\tconst result = searchResult.message.docs;\n\n\t\t\treturn API.v1.success({\n\t\t\t\tmessages: await normalizeMessagesForUser(result, this.userId),\n\t\t\t});","sourceCodeStart":856,"sourceCodeEnd":892,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/e4b8178b205510181a96ceefee043d0abcd13e5a/apps/meteor/server/api/v1/chat.ts#L856-L892","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Scope the search to a room the user can access: GET /api/v1/chat.search?roomId=GENERAL&searchText=hello.","Disable/guard the search action until a room is selected in your client.","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.","Resolve roomId from room name first via GET /api/v1/rooms.info?roomName=... when you only have the channel name."],"exampleFix":"// before\nrc.get('/api/v1/chat.search', { params: { searchText } }); // no roomId\n\n// after\nrc.get('/api/v1/chat.search', { params: { roomId: currentRoomId, searchText } });","handlingStrategy":"validation","validationCode":"if (typeof roomId !== 'string' || roomId.trim() === '') throw new Error('roomId is required for chat.search');\nawait rc.get('/api/v1/chat.search', { params: { roomId, searchText } });","typeGuard":"const isSearchQuery = (p: { roomId?: unknown; searchText?: unknown }): p is { roomId: string; searchText: string } =>\n  typeof p.roomId === 'string' && p.roomId.length > 0 &&\n  typeof p.searchText === 'string' && p.searchText.length > 0;","tryCatchPattern":"try {\n  await rc.get('/api/v1/chat.search', { params: { roomId, searchText } });\n} catch (e) {\n  if (e?.errorType === 'error-roomId-param-not-provided') disableSearchUntilRoomSelected();\n  else throw e;\n}","preventionTips":["chat.search is room-scoped by design; wire the search box to the currently open room's id.","Resolve channel names to ids via rooms.info?roomName= at startup instead of hardcoding."],"tags":["rocket-chat","rest-api","search","missing-parameter","chat-search"],"backgroundTag":"missing-required-argument","analyzedSha":"e4b8178b205510181a96ceefee043d0abcd13e5a","analyzedAt":"2026-08-18T15:26:39.429Z","contentChangedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}