{"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":870,"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":852,"sourceCodeEnd":888,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/f9d3ec372bb580fa8d036f94cf03925a478ef768/apps/meteor/server/api/v1/chat.ts#L852-L888","documentation":"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.","triggerScenarios":"GET /api/v1/chat.search?searchText=hello with no roomId; passing roomId under 'rid'; calling a global search variant that does not exist.","commonSituations":"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.","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."],"exampleFix":"// before\nGET /api/v1/chat.search?searchText=deploy\n// after\nGET /api/v1/chat.search?roomId=GENERAL&searchText=deploy","handlingStrategy":"validation","validationCode":"function buildSearchUrl(roomId: string, searchText: string) {\n  if (!roomId) throw new Error('roomId is required for chat.search');\n  const u = new URL('/api/v1/chat.search', location.origin);\n  u.searchParams.set('roomId', roomId);\n  u.searchParams.set('searchText', searchText);\n  return u;\n}","typeGuard":"const isSearchQuery = (q: unknown): q is { roomId: string; searchText: string } =>\n  typeof q === 'object' && q !== null &&\n  typeof (q as any).roomId === 'string' && (q as any).roomId.length > 0;","tryCatchPattern":"try {\n  await GET(searchUrl);\n} catch (e) {\n  if ((e as any)?.error === 'error-roomId-param-not-provided') {\n    // no active room — do not call search until one is selected\n  }\n  throw e;\n}","preventionTips":["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'."],"tags":["api","rest","validation","query-params","search","chat"],"backgroundTag":null,"analyzedSha":"f9d3ec372bb580fa8d036f94cf03925a478ef768","analyzedAt":"2026-08-12T19:07:17.372Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}