{"record":{"id":"ba9daee044195324","repo":"chroma-core/chroma","slug":"cannot-specify-both-hnsw-and-spann-configurati-ba9dae","errorCode":null,"errorMessage":"Cannot specify both 'hnsw' and 'spann' configurations during update.","messagePattern":"Cannot specify both 'hnsw' and 'spann' configurations during update\\.","errorType":"validation","errorClass":"InvalidConfigurationError","httpStatus":null,"severity":"error","filePath":"clients/js/packages/chromadb-core/src/CollectionConfiguration.ts","lineNumber":307,"sourceCode":"    config.sync_threshold = jsonMap.sync_threshold;\n  if (\"resize_factor\" in jsonMap) config.resize_factor = jsonMap.resize_factor;\n  return config;\n}\n\nexport function jsonToUpdateSpannConfiguration(\n  jsonMap: Record<string, any>,\n): UpdateSpannConfiguration {\n  const config: UpdateSpannConfiguration = {};\n  if (\"search_nprobe\" in jsonMap) config.search_nprobe = jsonMap.search_nprobe;\n  if (\"ef_search\" in jsonMap) config.ef_search = jsonMap.ef_search;\n  return config;\n}\n\nexport function updateCollectionConfigurationToJson(\n  config: UpdateCollectionConfiguration,\n): Record<string, any> {\n  if (config.hnsw && config.spann) {\n    throw new InvalidConfigurationError(\n      \"Cannot specify both 'hnsw' and 'spann' configurations during update.\",\n    );\n  }\n  let hnswConfig = config.hnsw;\n  let spannConfig = config.spann;\n  let ef = config.embedding_function;\n  let efConfig: Record<string, any> | null | undefined = undefined; // Initialize as undefined\n\n  // Validate HNSW config if present\n  if (hnswConfig) {\n    if (typeof hnswConfig !== \"object\") {\n      throw new Error(\n        \"Invalid HNSW config provided in UpdateCollectionConfiguration\",\n      );\n    }\n  }\n\n  // Validate SPANN config if present","sourceCodeStart":289,"sourceCodeEnd":325,"githubUrl":"https://github.com/chroma-core/chroma/blob/aecdd12c8a891610db8653630b066b32ceb678b5/clients/js/packages/chromadb-core/src/CollectionConfiguration.ts#L289-L325","documentation":"Update-time twin of the creation error: updateCollectionConfigurationToJson throws InvalidConfigurationError when an UpdateCollectionConfiguration contains both hnsw and spann. This code path runs from collection.modify({ configuration }) (Collection.ts) before the updateCollection API call. A collection can only be tuned for the index type it was created with; sending both is rejected client-side.","triggerScenarios":"collection.modify({ configuration: { hnsw: { search_ef: 200 }, spann: { search_nprobe: 5 } } }); any client.updateCollection-style flow that funnels through loadApiUpdateCollectionConfigurationFromUpdateCollectionConfiguration.","commonSituations":"Reusing the create-time configuration object (which already has hnsw) and adding spann fields for tuning; copy-pasted update snippets mixing HNSW and SPANN parameters; generic 'update all index knobs' helper that always sets both blocks.","solutions":["Send only the block matching the collection's actual index type: hnsw for HNSW collections, spann for SPANN collections.","Store which index type the collection was created with (or read it from collection.configuration) and build the update payload from that.","Pre-check the payload: if (cfg.hnsw && cfg.spann) throw before calling modify."],"exampleFix":"// before\nawait col.modify({\n  configuration: { hnsw: { search_ef: 200 }, spann: { search_nprobe: 5 } },\n});\n\n// after (collection was created with HNSW)\nawait col.modify({ configuration: { hnsw: { search_ef: 200 } } });","handlingStrategy":"validation","validationCode":"function assertUpdateSingleIndex(cfg: UpdateCollectionConfiguration) {\n  if (cfg.hnsw && cfg.spann) {\n    throw new Error('Update may target only the index type the collection was created with.');\n  }\n}\nassertUpdateSingleIndex(configuration);\nawait col.modify({ configuration });","typeGuard":"function isCleanUpdateConfig(\n  cfg: UpdateCollectionConfiguration,\n): cfg is UpdateCollectionConfiguration {\n  return !(cfg.hnsw && cfg.spann);\n}","tryCatchPattern":"try {\n  await col.modify({ configuration });\n} catch (e) {\n  if (e instanceof InvalidConfigurationError && e.message.includes('during update')) {\n    // keep only the block matching the collection's created index type and retry\n  }\n  throw e;\n}","preventionTips":["Derive update payloads from the collection's existing configuration instead of reusing create-time or copy-pasted objects.","Track the collection's index type in your own metadata and assert consistency before modify().","Write update helpers that accept exactly one index block."],"tags":["configuration","validation","hnsw","spann","update","collection-modify"],"backgroundTag":"conflicting-config-options","analyzedSha":"aecdd12c8a891610db8653630b066b32ceb678b5","analyzedAt":"2026-08-16T21:53:27.228Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}