chroma-core/chroma · error · ChromaValueError

Sparse embedding function returned unexpected number of embe

Error message

Sparse embedding function returned unexpected number of embeddings.

What it means

Error "Sparse embedding function returned unexpected number of embeddings." thrown in chroma-core/chroma.

Source

Thrown at clients/new-js/packages/chromadb/src/collection.ts:575

          if (index < documentsList.length) {
            const doc = documentsList[index];
            inputs.push(doc);
            positions.push(index);
          }
        });

        // Generate embeddings for all collected documents
        if (inputs.length === 0) {
          continue;
        }

        const sparseEmbeddings = await this.sparseEmbed(
          embeddingFunction,
          inputs,
          false,
        );
        if (sparseEmbeddings.length !== positions.length) {
          throw new ChromaValueError(
            "Sparse embedding function returned unexpected number of embeddings.",
          );
        }

        positions.forEach((position, idx) => {
          updatedMetadatas[position][targetKey] = sparseEmbeddings[idx];
        });

        continue; // Skip the metadata-based logic below
      }

      // Handle normal case: source_key is a metadata field
      updatedMetadatas.forEach((metadata, index) => {
        if (targetKey in metadata) {
          return;
        }

        const sourceValue = metadata[sourceKey];

View on GitHub (pinned to aecdd12c8a)

When it happens

Trigger: Thrown at clients/new-js/packages/chromadb/src/collection.ts:575 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of chroma-core/chroma@aecdd12c8a (2026-08-16). Data as JSON: /api/errors/a26a2156de17feef. Report an issue: GitHub.