{"record":{"id":"def6b006cc79cb63","repo":"Mintplex-Labs/anything-llm","slug":"query-parameter-cannot-be-empty","errorCode":null,"errorMessage":"Query parameter cannot be empty.","messagePattern":"Query parameter cannot be empty\\.","errorType":"http","errorClass":null,"httpStatus":400,"severity":"warning","filePath":"server/endpoints/api/workspace/index.js","lineNumber":966,"sourceCode":"              ]\n            }\n          }\n        }\n      }\n    }\n    */\n      try {\n        const { slug } = request.params;\n        const { query, topN, scoreThreshold } = reqBody(request);\n        const workspace = await Workspace.get({ slug: String(slug) });\n\n        if (!workspace)\n          return response.status(400).json({\n            message: `Workspace ${slug} is not a valid workspace.`,\n          });\n\n        if (!query?.length)\n          return response.status(400).json({\n            message: \"Query parameter cannot be empty.\",\n          });\n\n        const VectorDb = getVectorDbClass();\n        const hasVectorizedSpace = await VectorDb.hasNamespace(workspace.slug);\n        const embeddingsCount = await VectorDb.namespaceCount(workspace.slug);\n\n        if (!hasVectorizedSpace || embeddingsCount === 0)\n          return response.status(200).json({\n            results: [],\n            message: \"No embeddings found for this workspace.\",\n          });\n\n        const parseSimilarityThreshold = () => {\n          let input = parseFloat(scoreThreshold);\n          if (isNaN(input) || input < 0 || input > 1)\n            return workspace?.similarityThreshold ?? 0.25;\n          return input;","sourceCodeStart":948,"sourceCodeEnd":984,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/3aec848f2885144aa8f1e53b9731a04310d5d558/server/endpoints/api/workspace/index.js#L948-L984","documentation":"HTTP 400 from POST /api/v1/workspace/:slug/vector-search when the body's query is falsy or an empty string (!query?.length). The query is the text that will be embedded for similarity search, so an empty value has nothing to embed. topN and scoreThreshold are optional and unrelated to this error.","triggerScenarios":"POSTing {query:''} or omitting query entirely; sending {query:null}; a malformed JSON body (wrong Content-Type) so reqBody returns an empty object with no query key.","commonSituations":"Search input submitted without text; templated query strings that render to empty; client sends form-encoded body that the JSON parser ignores.","solutions":["Include a non-empty query string in the JSON body","Set Content-Type: application/json on the request","Guard client-side: skip the call when the search box is empty","Trim the query and reject empty results of the trim"],"exampleFix":"// before\nbody: JSON.stringify({ topN: 4 }) // forgot query\n// after\nbody: JSON.stringify({ query: q.trim(), topN: 4 })","handlingStrategy":"validation","validationCode":"const q = String(query ?? '').trim();\nif (!q) throw new Error('query required');\nbody = JSON.stringify({ query: q, topN, scoreThreshold });","typeGuard":"const hasQuery = (b) => typeof b?.query === 'string' && b.query.length > 0;","tryCatchPattern":null,"preventionTips":["Skip empty searches client-side","Send Content-Type: application/json","Integration-test the endpoint with a minimal {query:'test'} body first"],"tags":["anythingllm","developer-api","vector-search","request-body","http-400","validation"],"backgroundTag":"request-body-validation","analyzedSha":"3aec848f2885144aa8f1e53b9731a04310d5d558","analyzedAt":"2026-08-18T10:02:21.017Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}