Mintplex-Labs/anything-llm · error · Error

AstraDB:getOrCreateCollection Unable to infer vector dimensi

Error message

AstraDB:getOrCreateCollection Unable to infer vector dimension from input. Open an issue on Github for support.

What it means

In the AstraDB vector provider, getOrCreateCollection() must create a new collection with an explicit vector dimension because AstraDB does not infer it. The dimension is passed from the first chunk's embedding (vectorDimension = chunks[0][0].values.length). When the namespace does not exist yet AND dimensions is null/0, creation is impossible, so the provider throws and asks you to open an issue.

Source

Thrown at server/utils/vectorDbProviders/astra/index.js:133

  }

  async deleteVectorsInNamespace(client, namespace = null) {
    const sanitizedNamespace = sanitizeNamespace(namespace);
    await client.dropCollection(sanitizedNamespace);
    return true;
  }

  // AstraDB requires a dimension aspect for collection creation
  // we pass this in from the first chunk to infer the dimensions like other
  // providers do.
  async getOrCreateCollection(client, namespace, dimensions = null) {
    const sanitizedNamespace = sanitizeNamespace(namespace);
    try {
      const exists = await collectionExists(client, sanitizedNamespace);

      if (!exists) {
        if (!dimensions) {
          throw new Error(
            `AstraDB:getOrCreateCollection Unable to infer vector dimension from input. Open an issue on Github for support.`
          );
        }

        // Create new collection
        await client.createCollection(sanitizedNamespace, {
          vector: {
            dimension: dimensions,
            metric: "cosine",
          },
        });

        // Get the newly created collection
        return await client.collection(sanitizedNamespace);
      }

      return await client.collection(sanitizedNamespace);
    } catch (error) {

View on GitHub (pinned to 3aec848f28)

Solutions

  1. Verify the document actually produced text chunks (check document processing logs; try a plain .txt or text-heavy PDF as the first file).
  2. Confirm the embedding engine is healthy - test with a small workspace using the native embedder to rule out the embedder returning empty vectors.
  3. Pre-create the collection in the Astra dashboard (or via API) with dimension equal to your embedder output (e.g. 1536 for OpenAI text-embedding-3-small) so the null-dimension path is skipped.
  4. If chunks are non-empty and it still throws, capture documentVectors/embedding output and open the GitHub issue the message requests.
Defensive patterns

Strategy: validation

Validate before calling

const vectorValues = await LLMConnector.embedChunks(textChunks);
if (!vectorValues?.length || !vectorValues[0]?.length) {
  throw new Error('Embedding produced no vectors - check the embedding engine before ingesting.');
}
// only then call vectorDb.addDocumentToNamespace / getOrCreateCollection

Try / catch

try {
  await vectorDb.addDocumentToNamespace(namespace, fs.readFileSync(f), f, metadata);
} catch (e) {
  if (/infer vector dimension/i.test(e.message)) {
    console.error('First document in namespace had no embeddings - fix embedder and re-upload.');
  }
  throw e;
}

Prevention

When it happens

Trigger: First document embedded into a brand-new AstraDB namespace where the embedding step produced zero vectors (vectorDimension is never assigned), e.g. an empty/scanned-only PDF whose text extraction yielded no chunks, or an embedder that returned an empty array. Cached-vector path where cacheResult.chunks is empty also leaves vectorDimension null.

Common situations: Uploading image-only or empty PDFs as the very first document in a workspace; embedding engine misconfigured so embedTextInput/embedChunks silently returns []; switching embedders while the workspace is still empty.

Related errors


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