{"record":{"id":"b060fca82f1207e7","repo":"Mintplex-Labs/anything-llm","slug":"invalid-request-to-performsimilaritysearch-b060fc","errorCode":null,"errorMessage":"Invalid request to performSimilaritySearch.","messagePattern":"Invalid request to performSimilaritySearch\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/utils/vectorDbProviders/lance/index.js","lineNumber":427,"sourceCode":"      await DocumentVectors.bulkInsert(documentVectors);\n      return { vectorized: true, error: null };\n    } catch (e) {\n      this.logger(\"addDocumentToNamespace\", e.message);\n      return { vectorized: false, error: e.message };\n    }\n  }\n\n  async performSimilaritySearch({\n    namespace = null,\n    input = \"\",\n    LLMConnector = null,\n    similarityThreshold = 0.25,\n    topN = 4,\n    filterIdentifiers = [],\n    rerank = false,\n  }) {\n    if (!namespace || !input || !LLMConnector)\n      throw new Error(\"Invalid request to performSimilaritySearch.\");\n\n    const { client } = await this.connect();\n    if (!(await this.namespaceExists(client, namespace))) {\n      return {\n        contextTexts: [],\n        sources: [],\n        message: \"Invalid query - no documents found for workspace!\",\n      };\n    }\n\n    const queryVector = await LLMConnector.embedTextInput(input);\n    const result = rerank\n      ? await this.rerankedSimilarityResponse({\n          client,\n          namespace,\n          query: input,\n          queryVector,\n          similarityThreshold,","sourceCodeStart":409,"sourceCodeEnd":445,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/20f6d3546c1938bfea1ad304f58a592dddcc5948/server/utils/vectorDbProviders/lance/index.js#L409-L445","documentation":"LanceVectorDb.performSimilaritySearch requires non-empty namespace, input, and LLMConnector; any falsy value throws immediately. The LLMConnector supplies embedTextInput() to build the query vector, and an optional rerank flag chooses the reranked query path. Used by chat retrieval and the agent memory plugin.","triggerScenarios":"Retrieval invoked with a null workspace slug, blank query, or a missing connector - custom integrations calling VectorDb.performSimilaritySearch directly, or races where the workspace was deleted before the chat completed.","commonSituations":"Custom middleware/AI-plugin code omitting LLMConnector; empty prompt reaching retrieval; tests with placeholder objects; workspace.slug undefined because the workspace record was not loaded.","solutions":["Supply all three required arguments; obtain LLMConnector from getLLMProvider() with the workspace's model settings.","Short-circuit empty/whitespace queries in your handler before retrieval.","Load and verify the workspace (slug present) before dispatching the search."],"exampleFix":"// before\nconst results = await VectorDb.performSimilaritySearch({ namespace, input });\n\n// after\nif (!namespace || !input?.trim()) return { contextTexts: [], sources: [] };\nconst results = await VectorDb.performSimilaritySearch({\n  namespace,\n  input: input.trim(),\n  LLMConnector,\n});","handlingStrategy":"validation","validationCode":"function assertLanceSearchArgs({ namespace, input, LLMConnector }) {\n  if (!namespace) throw new Error('namespace required');\n  if (!input?.trim()) throw new Error('input required');\n  if (!LLMConnector?.embedTextInput) throw new Error('LLMConnector with embedTextInput required');\n}","typeGuard":"function isValidLanceSearchRequest(req) {\n  return !!req?.namespace && typeof req.input === 'string' && req.input.trim().length > 0\n    && typeof req.LLMConnector?.embedTextInput === 'function';\n}","tryCatchPattern":null,"preventionTips":["Build retrieval calls from a loaded workspace and early-return when the slug or query is missing.","Use getLLMProvider() for the connector in every retrieval path."],"tags":["lancedb","vector-db","similarity-search","argument-validation"],"backgroundTag":"missing-required-argument","analyzedSha":"20f6d3546c1938bfea1ad304f58a592dddcc5948","analyzedAt":"2026-08-18T10:02:21.017Z","contentChangedAt":"2026-08-18T10:02:21.017Z","schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}