chroma-core/chroma · error · Error

Cannot enable all index types for key '${key}'. Please speci

Error message

Cannot enable all index types for key '${key}'. Please specify a specific index configuration.

What it means

The mirror image of the no-argument createIndex error: passing a key with no config would mean 'enable every index type for this key', which the schema API disallows (a TODO in the source notes this may be relaxed later). Each call must name a concrete IndexConfig. In this version the only grounded per-key configs are FtsIndexConfig on '#document' and SparseVectorIndexConfig on a user key.

Source

Thrown at clients/new-js/packages/chromadb/src/schema.ts:570

    if (
      config instanceof FtsIndexConfig &&
      (!keyProvided || key !== DOCUMENT_KEY)
    ) {
      throw new Error(
        "FTS index can only be enabled on #document key. Use createIndex(new FtsIndexConfig(), '#document')",
      );
    }

    if (config instanceof SparseVectorIndexConfig && !keyProvided) {
      throw new Error(
        "Sparse vector index must be created on a specific key. Please specify a key using: createIndex(new SparseVectorIndexConfig(...), 'your_key')",
      );
    }

    // TODO: Consider removing this check in the future to allow enabling all indexes for a key
    // Disallow enabling all index types for a key (config=undefined, key="some_key")
    if (!configProvided && keyProvided && key) {
      throw new Error(
        `Cannot enable all index types for key '${key}'. Please specify a specific index configuration.`,
      );
    }

    if (configProvided && !keyProvided) {
      this.setIndexInDefaults(config as IndexConfig, true);
    } else if (configProvided && keyProvided && key) {
      this.setIndexForKey(key, config as IndexConfig, true);
    }

    return this;
  }

  deleteIndex(config?: IndexConfig, key?: string): this {
    const configProvided = config !== undefined && config !== null;
    const keyProvided = key !== undefined && key !== null;

    if (!configProvided && !keyProvided) {

View on GitHub (pinned to aecdd12c8a)

Solutions

  1. Pick a concrete config for that key, e.g. createIndex(new SparseVectorIndexConfig(...), 'title').
  2. If the intent was a global setting, pass the config without a key instead (e.g. a global VectorIndexConfig).
  3. Guard optional paths: only call createIndex when you actually have a config to apply.

Example fix

// before
schema.createIndex(undefined, 'title');

// after
schema.createIndex(new SparseVectorIndexConfig(), 'title'); // concrete per-key config
Defensive patterns

Strategy: validation

Validate before calling

function createIndexForKey(schema: Schema, config: IndexConfig | null | undefined, key: string): void {
  if (config === undefined || config === null) {
    throw new Error(`A concrete IndexConfig is required for key '${key}'`);
  }
  schema.createIndex(config, key);
}

Type guard

const hasConcreteConfig = (config?: IndexConfig | null): config is IndexConfig =>
  config !== undefined && config !== null;

Try / catch

try {
  schema.createIndex(config, key);
} catch (e) {
  if (e instanceof Error && e.message.startsWith('Cannot enable all index types for key')) {
    // choose a concrete config for the key and retry
  } else {
    throw e;
  }
}

Prevention

When it happens

Trigger: schema.createIndex(undefined, 'title'); schema.createIndex(null, 'title'); a ternary that yields an undefined config while the key is still passed.

Common situations: A SQL 'CREATE INDEX ON column' mental model where no index type is needed; optional config objects that fail a runtime condition; refactoring that moved the config argument away.

Related errors


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