Mintplex-Labs/anything-llm · error · Error
Invalid request to performSimilaritySearch.
Error message
Invalid request to performSimilaritySearch.
What it means
ChromaVectorDb.performSimilaritySearch destructures { namespace, input, LLMConnector } and immediately throws if any of the three is falsy. This is an internal API used by chat flows (chats/stream.js, embed.js, apiChatHandler) and by the workspace /api endpoint for RAG retrieval; the guard prevents querying with an unscoped namespace, empty query, or missing embedder connector.
Source
Thrown at server/utils/vectorDbProviders/chroma/index.js:379
const vectorIds = knownDocuments.map((doc) => doc.vectorId);
await this.smartDelete(collection, vectorIds);
const indexes = knownDocuments.map((doc) => doc.id);
await DocumentVectors.deleteIds(indexes);
return true;
}
async performSimilaritySearch({
namespace = null,
input = "",
LLMConnector = null,
similarityThreshold = 0.25,
topN = 4,
filterIdentifiers = [],
}) {
if (!namespace || !input || !LLMConnector)
throw new Error("Invalid request to performSimilaritySearch.");
const { client } = await this.connect();
if (!(await this.namespaceExists(client, this.normalize(namespace)))) {
return {
contextTexts: [],
sources: [],
message: "Invalid query - no documents found for workspace!",
};
}
const queryVector = await LLMConnector.embedTextInput(input);
const { contextTexts, sourceDocuments, scores } =
await this.similarityResponse({
client,
namespace,
queryVector,
similarityThreshold,
topN,View on GitHub (pinned to 20f6d3546c)
Solutions
- Pass all three required params: a non-empty namespace (workspace slug), non-empty input, and the LLMConnector (from getLLMProvider) that embeds the query.
- In custom code, fetch the workspace first and bail early if it (or its slug) is missing.
- Trim/validate user input before invoking retrieval so empty queries short-circuit in your handler.
Example fix
// before
const results = await VectorDb.performSimilaritySearch({
namespace: workspace?.slug,
input,
});
// after
if (!workspace?.slug || !input?.trim()) return { contextTexts: [], sources: [] };
const LLMConnector = getLLMProvider({ model });
const results = await VectorDb.performSimilaritySearch({
namespace: workspace.slug,
input: input.trim(),
LLMConnector,
}); Defensive patterns
Strategy: validation
Validate before calling
function assertSimilaritySearchArgs({ namespace, input, LLMConnector }) {
if (!namespace) throw new Error('namespace is required');
if (!input?.trim()) throw new Error('input is required');
if (!LLMConnector || typeof LLMConnector.embedTextInput !== 'function') {
throw new Error('LLMConnector with embedTextInput() is required');
}
} Type guard
function isValidSearchRequest(req) {
return !!req?.namespace && typeof req.input === 'string' && req.input.trim().length > 0
&& !!req.LLMConnector && typeof req.LLMConnector.embedTextInput === 'function';
} Prevention
- In custom retrieval code, always build args from a loaded workspace record and early-return on missing slugs.
- Trim and reject empty queries in the handler before calling retrieval.
- Reuse getLLMProvider() for the connector instead of hand-constructing one.
When it happens
Trigger: Calling performSimilaritySearch({ namespace: null, ... }) from custom code, a workspace whose slug is undefined, an empty query string reaching the retrieval layer, or forgetting to pass the LLM connector that provides embedTextInput() for the query vector.
Common situations: Custom integrations/middleware calling VectorDb.performSimilaritySearch directly; race where the workspace record is gone before the chat executes; tests invoking the method with placeholder args.
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
- namespace required
- Invalid request to performSimilaritySearch.
- Chroma::Invalid ENV settings
- ChromaDB::Invalid Heartbeat received - is the instance onlin
- Could not embed document chunks! This document will not be r
AI-assisted analysis of Mintplex-Labs/anything-llm@20f6d3546c (2026-08-18).
Data as JSON: /api/errors/89791422ba3c8c5c.
Report an issue: GitHub.