{"record":{"id":"ed49eb2db9c0a503","repo":"Mintplex-Labs/anything-llm","slug":"astradb-getorcreatecollection-unable-to-infer-vect","errorCode":null,"errorMessage":"AstraDB:getOrCreateCollection Unable to infer vector dimension from input. Open an issue on Github for support.","messagePattern":"AstraDB:getOrCreateCollection Unable to infer vector dimension from input\\. Open an issue on Github for support\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/utils/vectorDbProviders/astra/index.js","lineNumber":133,"sourceCode":"  }\n\n  async deleteVectorsInNamespace(client, namespace = null) {\n    const sanitizedNamespace = sanitizeNamespace(namespace);\n    await client.dropCollection(sanitizedNamespace);\n    return true;\n  }\n\n  // AstraDB requires a dimension aspect for collection creation\n  // we pass this in from the first chunk to infer the dimensions like other\n  // providers do.\n  async getOrCreateCollection(client, namespace, dimensions = null) {\n    const sanitizedNamespace = sanitizeNamespace(namespace);\n    try {\n      const exists = await collectionExists(client, sanitizedNamespace);\n\n      if (!exists) {\n        if (!dimensions) {\n          throw new Error(\n            `AstraDB:getOrCreateCollection Unable to infer vector dimension from input. Open an issue on Github for support.`\n          );\n        }\n\n        // Create new collection\n        await client.createCollection(sanitizedNamespace, {\n          vector: {\n            dimension: dimensions,\n            metric: \"cosine\",\n          },\n        });\n\n        // Get the newly created collection\n        return await client.collection(sanitizedNamespace);\n      }\n\n      return await client.collection(sanitizedNamespace);\n    } catch (error) {","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/3aec848f2885144aa8f1e53b9731a04310d5d558/server/utils/vectorDbProviders/astra/index.js#L115-L151","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Verify the document actually produced text chunks (check document processing logs; try a plain .txt or text-heavy PDF as the first file).","Confirm the embedding engine is healthy - test with a small workspace using the native embedder to rule out the embedder returning empty vectors.","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.","If chunks are non-empty and it still throws, capture documentVectors/embedding output and open the GitHub issue the message requests."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const vectorValues = await LLMConnector.embedChunks(textChunks);\nif (!vectorValues?.length || !vectorValues[0]?.length) {\n  throw new Error('Embedding produced no vectors - check the embedding engine before ingesting.');\n}\n// only then call vectorDb.addDocumentToNamespace / getOrCreateCollection","typeGuard":null,"tryCatchPattern":"try {\n  await vectorDb.addDocumentToNamespace(namespace, fs.readFileSync(f), f, metadata);\n} catch (e) {\n  if (/infer vector dimension/i.test(e.message)) {\n    console.error('First document in namespace had no embeddings - fix embedder and re-upload.');\n  }\n  throw e;\n}","preventionTips":["Never ingest into an empty AstraDB namespace without confirming the embedder returns vectors (test-embed one string first).","Pre-create the Astra collection with your embedder's dimension when automating workspace bootstrap.","Reject empty-extraction documents before they reach the embedding stage."],"tags":["astradb","vector-db","embedding-dimension","document-ingestion"],"backgroundTag":"embedding-dimension-missing","analyzedSha":"3aec848f2885144aa8f1e53b9731a04310d5d558","analyzedAt":"2026-08-18T10:02:21.017Z","contentChangedAt":"2026-08-18T10:02:21.017Z","schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}