Mintplex-Labs/anything-llm · error · Error

Invalid request to performSimilaritySearch.

Error message

Invalid request to performSimilaritySearch.

What it means

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.

Source

Thrown at server/utils/vectorDbProviders/lance/index.js:427

      await DocumentVectors.bulkInsert(documentVectors);
      return { vectorized: true, error: null };
    } catch (e) {
      this.logger("addDocumentToNamespace", e.message);
      return { vectorized: false, error: e.message };
    }
  }

  async performSimilaritySearch({
    namespace = null,
    input = "",
    LLMConnector = null,
    similarityThreshold = 0.25,
    topN = 4,
    filterIdentifiers = [],
    rerank = false,
  }) {
    if (!namespace || !input || !LLMConnector)
      throw new Error("Invalid request to performSimilaritySearch.");

    const { client } = await this.connect();
    if (!(await this.namespaceExists(client, namespace))) {
      return {
        contextTexts: [],
        sources: [],
        message: "Invalid query - no documents found for workspace!",
      };
    }

    const queryVector = await LLMConnector.embedTextInput(input);
    const result = rerank
      ? await this.rerankedSimilarityResponse({
          client,
          namespace,
          query: input,
          queryVector,
          similarityThreshold,

View on GitHub (pinned to 20f6d3546c)

Solutions

  1. Supply all three required arguments; obtain LLMConnector from getLLMProvider() with the workspace's model settings.
  2. Short-circuit empty/whitespace queries in your handler before retrieval.
  3. Load and verify the workspace (slug present) before dispatching the search.

Example fix

// before
const results = await VectorDb.performSimilaritySearch({ namespace, input });

// after
if (!namespace || !input?.trim()) return { contextTexts: [], sources: [] };
const results = await VectorDb.performSimilaritySearch({
  namespace,
  input: input.trim(),
  LLMConnector,
});
Defensive patterns

Strategy: validation

Validate before calling

function assertLanceSearchArgs({ namespace, input, LLMConnector }) {
  if (!namespace) throw new Error('namespace required');
  if (!input?.trim()) throw new Error('input required');
  if (!LLMConnector?.embedTextInput) throw new Error('LLMConnector with embedTextInput required');
}

Type guard

function isValidLanceSearchRequest(req) {
  return !!req?.namespace && typeof req.input === 'string' && req.input.trim().length > 0
    && typeof req.LLMConnector?.embedTextInput === 'function';
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of Mintplex-Labs/anything-llm@20f6d3546c (2026-08-18). Data as JSON: /api/errors/b060fca82f1207e7. Report an issue: GitHub.