{"record":{"id":"52677945b6afaf24","repo":"RocketChat/Rocket.Chat","slug":"error-searchtext-param-not-provided","errorCode":"error-searchText-param-not-provided","errorMessage":"The required \"searchText\" query param is missing.","messagePattern":"The required \"searchText\" query param is missing\\.","errorType":"exception","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/api/v1/chat.ts","lineNumber":878,"sourceCode":"\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});\n\t\t},\n\t)\n\t// The difference between `chat.postMessage` and `chat.sendMessage` is that `chat.sendMessage` allows\n\t// for passing a value for `_id` and the other one doesn't. Also, `chat.sendMessage` only sends it to","sourceCodeStart":860,"sourceCodeEnd":896,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/e4b8178b205510181a96ceefee043d0abcd13e5a/apps/meteor/server/api/v1/chat.ts#L860-L896","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Send a non-empty term: GET /api/v1/chat.search?roomId=GENERAL&searchText=deploy.","Suppress the request when input.trim() is empty in the client.","If the intent was listing messages, use chat.syncMessages instead of an empty search.","Treat this error as a no-op result in UI flows (show 'no results') rather than an error banner."],"exampleFix":"// before\nif (query !== undefined) search(query); // '' sneaks through\n\n// after\nconst term = query?.trim();\nif (term) search(term);","handlingStrategy":"validation","validationCode":"const term = typeof searchText === 'string' ? searchText.trim() : '';\nif (!term) return emptyResult(); // skip the request entirely\nawait rc.get('/api/v1/chat.search', { params: { roomId, searchText: term } });","typeGuard":"const hasSearchTerm = (p: { searchText?: unknown }): p is { searchText: string } =>\n  typeof p.searchText === 'string' && p.searchText.trim().length > 0;","tryCatchPattern":"try {\n  await rc.get('/api/v1/chat.search', { params: { roomId, searchText } });\n} catch (e) {\n  if (e?.errorType === 'error-searchText-param-not-provided') return { messages: [] }; // treat as no-op\n  else throw e;\n}","preventionTips":["Suppress search requests on empty/whitespace input (empty string passes schema - only you catch it).","Debounce the search box and cancel in-flight empty queries."],"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"}