chroma-core/chroma · error · ChromaValueError

Cannot specify both HNSW and SPANN configurations

Error message

Cannot specify both HNSW and SPANN configurations

What it means

processCreateCollectionConfig() guard: the CreateCollectionConfiguration supplied both `hnsw` and `spann` blocks. A collection can use only one ANN index implementation, so providing both is rejected as ambiguous.

Solutions

  1. Keep only the hnsw or the spann block in the configuration, not both
  2. Choose the index type based on dataset size/latency requirements before creating the collection
  3. Omit both to use server defaults
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at clients/new-js/packages/chromadb/src/collection-configuration.ts:74 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/0e239e82f19ee061. Report an issue: GitHub.

Appendix: source

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

 * CollectionConfiguration to be used in collection creation.
 */
export const processCreateCollectionConfig = async ({
  configuration,
  embeddingFunction,
  metadata,
  schema,
}: {
  configuration?: CreateCollectionConfiguration;
  embeddingFunction?: EmbeddingFunction | null;
  metadata?: CollectionMetadata;
  schema?: Schema;
}) => {
  let schemaEmbeddingFunction: EmbeddingFunction | null | undefined = undefined;
  if (schema) {
    schemaEmbeddingFunction = schema.resolveEmbeddingFunction();
  }
  if (configuration?.hnsw && configuration?.spann) {
    throw new ChromaValueError(
      "Cannot specify both HNSW and SPANN configurations",
    );
  }

  let embeddingFunctionConfiguration = serializeEmbeddingFunction({
    embeddingFunction: embeddingFunction ?? undefined,
    configEmbeddingFunction: configuration?.embeddingFunction,
  });

  if (
    !embeddingFunctionConfiguration &&
    embeddingFunction !== null &&
    schemaEmbeddingFunction === undefined
  ) {
    embeddingFunctionConfiguration = await getDefaultEFConfig();
  }

  const overallEf = embeddingFunction || configuration?.embeddingFunction;

View on GitHub (pinned to aecdd12c8a)