{"record":{"id":"b66ac86c8f207120","repo":"chroma-core/chroma","slug":"cannot-disable-all-indexes-must-specify-either-co","errorCode":null,"errorMessage":"Cannot disable all indexes. Must specify either config or key.","messagePattern":"Cannot disable all indexes\\. Must specify either config or key\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"clients/new-js/packages/chromadb/src/schema.ts","lineNumber":589,"sourceCode":"        `Cannot enable all index types for key '${key}'. Please specify a specific index configuration.`,\n      );\n    }\n\n    if (configProvided && !keyProvided) {\n      this.setIndexInDefaults(config as IndexConfig, true);\n    } else if (configProvided && keyProvided && key) {\n      this.setIndexForKey(key, config as IndexConfig, true);\n    }\n\n    return this;\n  }\n\n  deleteIndex(config?: IndexConfig, key?: string): this {\n    const configProvided = config !== undefined && config !== null;\n    const keyProvided = key !== undefined && key !== null;\n\n    if (!configProvided && !keyProvided) {\n      throw new Error(\n        \"Cannot disable all indexes. Must specify either config or key.\",\n      );\n    }\n\n    // Disallow using special internal key #embedding\n    if (keyProvided && key && key === EMBEDDING_KEY) {\n      throw new Error(\"Cannot modify #embedding. Currently not supported\");\n    }\n\n    // Only allow #document with FtsIndexConfig (to disable FTS)\n    if (\n      keyProvided &&\n      key === DOCUMENT_KEY &&\n      !(config instanceof FtsIndexConfig)\n    ) {\n      throw new Error(\n        `Cannot delete index on special key '${key}' with this config. Only FtsIndexConfig is allowed for #document.`,\n      );","sourceCodeStart":571,"sourceCodeEnd":607,"githubUrl":"https://github.com/chroma-core/chroma/blob/aecdd12c8a891610db8653630b066b32ceb678b5/clients/new-js/packages/chromadb/src/schema.ts#L571-L607","documentation":"deleteIndex mirrors createIndex's argument contract: it needs an IndexConfig, a key, or both, because deleting every index in one call is not supported. Calling deleteIndex() with both arguments absent (undefined/null) throws immediately.","triggerScenarios":"schema.deleteIndex(); schema.deleteIndex(undefined, undefined); teardown/reset code that calls deleteIndex unconditionally with optional variables.","commonSituations":"Collection reset or teardown scripts; TypeScript allowing the call because both parameters are optional; copy-pasting a createIndex call and deleting an argument.","solutions":["Delete a specific index: deleteIndex(new FtsIndexConfig(), '#document') for full-text search.","For a full reset, recreate the collection with a fresh Schema instead of deleting every index.","Guard optional deletes: if (cfg) schema.deleteIndex(cfg, key)."],"exampleFix":"// before\nschema.deleteIndex();\n\n// after\nschema.deleteIndex(new FtsIndexConfig(), '#document'); // delete FTS specifically","handlingStrategy":"validation","validationCode":"function deleteIndexSafe(schema: Schema, config?: IndexConfig | null, key?: string | null): void {\n  const hasConfig = config !== undefined && config !== null;\n  const hasKey = key !== undefined && key !== null;\n  if (!hasConfig && !hasKey) {\n    throw new Error('deleteIndex requires a config and/or a key — full teardown is not supported');\n  }\n  schema.deleteIndex(config ?? undefined, key ?? undefined);\n}","typeGuard":"const hasDeleteTarget = (config?: IndexConfig | null, key?: string | null): boolean =>\n  (config !== undefined && config !== null) ||\n  (key !== undefined && key !== null);","tryCatchPattern":"try {\n  schema.deleteIndex(config, key);\n} catch (e) {\n  if (e instanceof Error && e.message === 'Cannot disable all indexes. Must specify either config or key.') {\n    // delete indexes individually instead of all at once\n  } else {\n    throw e;\n  }\n}","preventionTips":["Treat teardown as per-index deletion; plan a recreate-collection path for full resets.","Wrap deleteIndex so both-optional calls fail fast with your own clearer message."],"tags":["schema","index-config","teardown","chroma"],"backgroundTag":"invalid-index-configuration","analyzedSha":"aecdd12c8a891610db8653630b066b32ceb678b5","analyzedAt":"2026-08-16T21:53:27.228Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}