Mintplex-Labs/anything-llm · error · Error

res.statusText || "Error fetching api keys."

Error message

res.statusText || "Error fetching api keys."

What it means

The Qdrant twin of the Pinecone guard: performSimilaritySearch requires a namespace, a non-empty input, and an LLMConnector to embed the query; any falsy value throws before touching Qdrant. Note the behavioral difference downstream: for a merely non-existent namespace the Qdrant provider returns an empty result with a message instead of throwing, so this specific throw is strictly about missing/empty arguments.

Solutions

  1. Supply all three fields: { namespace, input: input.trim(), LLMConnector } with a non-empty input.
  2. If hit during normal chat, configure and save a working embedding engine first — LLMConnector is null when none resolves.
  3. Validate/trim the prompt upstream so blank inputs never reach the search call.
  4. For a missing-namespace case you will not get this throw (Qdrant returns empty results) — focus on the argument contract itself.

Example fix

// before
const r = await vectorDB.performSimilaritySearch({ namespace, input: '' });

// after
if (!namespace) throw new Error('namespace required');
if (!input?.trim()) return { contextTexts: [], sources: [], message: 'Empty query' };
const LLMConnector = getEmbeddingEngineSelection();
if (!LLMConnector) throw new Error('No embedding engine configured');
const r = await vectorDB.performSimilaritySearch({ namespace, input: input.trim(), LLMConnector });
Defensive patterns

Strategy: type-guard

Validate before calling

const missing = [!namespace && 'namespace', !input?.trim() && 'input', !LLMConnector && 'LLMConnector'].filter(Boolean);
if (missing.length > 0) {
  throw new Error(`performSimilaritySearch missing: ${missing.join(', ')}`);
}
await vectorDB.performSimilaritySearch({ namespace, input: input.trim(), LLMConnector });

Type guard

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

Try / catch

try {
  const r = await vectorDB.performSimilaritySearch({ namespace, input, LLMConnector });
} catch (e) {
  if (/Invalid request to performSimilaritySearch/.test(e.message)) {
    // argument-contract bug in the caller; note Qdrant returns empty results (no throw) for missing namespaces
    return { contextTexts: [], sources: [], message: 'Invalid search request' };
  }
  throw e;
}

Prevention

When it happens

Trigger: Custom code calling performSimilaritySearch({ namespace }) with no input; input: '' or whitespace after trimming; LLMConnector null because no embedding engine is configured (missing API key for the selected engine); plugins constructing the argument object manually with wrong keys.

Common situations: Plugins/scripts invoking the provider directly; embedding engine unset or its key removed after workspaces existed; blank chat input reaching the search layer after a refactor; renamed argument fields during upgrades.

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@3aec848f28 (2026-08-18). Data as JSON: /api/errors/e2b5473df67d040e. Report an issue: GitHub.

Appendix: source

Thrown at frontend/src/models/admin.js:199

      headers: baseHeaders(),
      body: JSON.stringify(updates),
    })
      .then((res) => res.json())
      .catch((e) => {
        console.error(e);
        return { success: false, error: e.message };
      });
  },

  // API Keys
  getApiKeys: async function () {
    return fetch(`${API_BASE}/admin/api-keys`, {
      method: "GET",
      headers: baseHeaders(),
    })
      .then((res) => {
        if (!res.ok) {
          throw new Error(res.statusText || "Error fetching api keys.");
        }
        return res.json();
      })
      .catch((e) => {
        console.error(e);
        return { apiKeys: [], error: e.message };
      });
  },
  generateApiKey: async function (data = {}) {
    return fetch(`${API_BASE}/admin/generate-api-key`, {
      method: "POST",
      headers: baseHeaders(),
      body: JSON.stringify(data),
    })
      .then((res) => {
        if (!res.ok) {
          throw new Error(res.statusText || "Error generating api key.");
        }

View on GitHub (pinned to 3aec848f28)