Mintplex-Labs/anything-llm · error · Error

Error embedding into ChromaDB: ${error.message}

Error message

Error embedding into ChromaDB: ${error.message}

What it means

Thrown by ChromaVectorDb.addDocumentToNamespace when smartAdd(collection, submission) rejects during the actual upsert; the original SDK error message is wrapped as 'Error embedding into ChromaDB: <message>'. The outer catch converts it to { vectorized: false, error } so the API does not crash, but the document is not stored.

Source

Thrown at server/utils/vectorDbProviders/chroma/index.js:337

      const { client } = await this.connect();
      const collection = await client.getOrCreateCollection({
        name: this.normalize(namespace),
        metadata: { "hnsw:space": "cosine" },
      });

      if (vectors.length > 0) {
        const chunks = [];
        this.logger("Inserting vectorized chunks into Chroma collection.");
        for (const chunk of toChunks(vectors, 500)) chunks.push(chunk);

        try {
          await this.smartAdd(collection, submission);
          this.logger(
            `Successfully added ${submission.ids.length} vectors to collection ${this.normalize(namespace)}`
          );
        } catch (error) {
          this.logger("Error adding to ChromaDB:", error);
          throw new Error(`Error embedding into ChromaDB: ${error.message}`);
        }

        await storeVectorResult(chunks, fullFilePath);
      }

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

  async deleteDocumentFromNamespace(namespace, docId) {
    const { DocumentVectors } = require("../../../models/vectors");
    const { client } = await this.connect();
    if (!(await this.namespaceExists(client, namespace))) return;
    const collection = await client.getCollection({

View on GitHub (pinned to 20f6d3546c)

Solutions

  1. Read the wrapped message - it carries the underlying Chroma error; dimension mismatches usually say 'Expected X-dimensional vector, got Y'.
  2. If dimensions conflict, delete the workspace's collection (or the whole namespace) so it is recreated with the current embedder's dimension.
  3. Sanitize metadata to scalar values (string/number/bool) before embedding documents.
  4. For transient network errors, re-run the embed; vector-cache makes retries cheap.
Defensive patterns

Strategy: try-catch

Try / catch

const r = await vectorDb.addDocumentToNamespace(namespace, buffer, filePath, metadata);
if (!r.vectorized) {
  if (/dimension/i.test(r.error)) {
    await vectorDb['delete-namespace']({ namespace }); // recreate with current dimension
    return vectorDb.addDocumentToNamespace(namespace, buffer, filePath, metadata);
  }
  if (/ECONNRESET|fetch failed/i.test(r.error)) return retryLater(); // transient
  throw new Error(r.error);
}

Prevention

When it happens

Trigger: Upsert failures such as embedding-dimension mismatch between existing collection and new vectors, invalid metadata types (Chroma rejects nested/None-scalar values), batch rejected due to size limits, or connection reset mid-write.

Common situations: Switching EMBEDDING_ENGINE after the workspace collection was created (dimension conflict); Chroma upgraded with stricter metadata validation; network blips to a remote Chroma; sending metadata containing null or nested objects.

Related errors


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