{"record":{"id":"ff877f0a96c13054","repo":"chroma-core/chroma","slug":"invalid-spann-config-provided-in-updatecollectionc","errorCode":null,"errorMessage":"Invalid SPANN config provided in UpdateCollectionConfiguration","messagePattern":"Invalid SPANN config provided in UpdateCollectionConfiguration","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"clients/js/packages/chromadb-core/src/CollectionConfiguration.ts","lineNumber":328,"sourceCode":"  }\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\n  if (spannConfig) {\n    if (typeof spannConfig !== \"object\") {\n      throw new Error(\n        \"Invalid SPANN config provided in UpdateCollectionConfiguration\",\n      );\n    }\n  }\n\n  // Handle embedding function serialization only if explicitly provided (ef !== undefined)\n  if (ef !== undefined) {\n    efConfig = serializeEmbeddingFunction(ef);\n  }\n\n  // Construct the result object, only including defined fields\n  const result: Record<string, any> = {};\n  if (hnswConfig !== undefined) result.hnsw = hnswConfig;\n  if (spannConfig !== undefined) result.spann = spannConfig;\n  if (efConfig !== undefined) result.embedding_function = efConfig;\n\n  // Check if the result is empty, which means no valid update fields were provided\n  if (Object.keys(result).length === 0) {","sourceCodeStart":310,"sourceCodeEnd":346,"githubUrl":"https://github.com/chroma-core/chroma/blob/aecdd12c8a891610db8653630b066b32ceb678b5/clients/js/packages/chromadb-core/src/CollectionConfiguration.ts#L310-L346","documentation":"updateCollectionConfigurationToJson's SPANN shape check: if the spann field of an UpdateCollectionConfiguration is truthy but typeof is not 'object', this plain Error is thrown before the network request. UpdateSpannConfiguration is a partial object deserialized from fields like { search_nprobe, ef_search }; only those keys are copied into the payload (see the sibling updateSpannConfigurationFromJson helper).","triggerScenarios":"collection.modify({ configuration: { spann: 10 } }); spann: 'nprobe 10'; spann set from an unparsed string in a dynamically built update payload.","commonSituations":"Assuming spann is a number of probes rather than an options object; passing serialized JSON from a job queue message; merging loose env-var strings into the update configuration.","solutions":["Use the object form: { spann: { search_nprobe: 10, ef_search: 64 } }.","Parse string sources with JSON.parse before assignment.","Add a typeof cfg.spann === 'object' validation step in your update helper."],"exampleFix":"// before\nawait col.modify({ configuration: { spann: 10 } });\n\n// after\nawait col.modify({ configuration: { spann: { search_nprobe: 10 } } });","handlingStrategy":"type-guard","validationCode":"if (cfg.spann !== undefined && typeof cfg.spann !== 'object') {\n  throw new TypeError('update spann must be an object like { search_nprobe: 10 }');\n}","typeGuard":"function isUpdateSpann(v: unknown): v is UpdateSpannConfiguration {\n  return typeof v === 'object' && v !== null && !Array.isArray(v);\n}","tryCatchPattern":"try {\n  await col.modify({ configuration });\n} catch (e) {\n  if (e instanceof Error && e.message.includes('Invalid SPANN config provided in UpdateCollectionConfiguration')) {\n    // replace the primitive with an options object and retry\n  }\n  throw e;\n}","preventionTips":["Search nprobe is a field inside the object, not the object itself.","Validate the shape at your config boundary instead of trusting env/queue payloads.","Keep SPANN update snippets in one shared helper so the correct shape is enforced once."],"tags":["configuration","validation","spann","type-mismatch","update","collection-modify"],"backgroundTag":"config-type-mismatch","analyzedSha":"aecdd12c8a891610db8653630b066b32ceb678b5","analyzedAt":"2026-08-16T21:53:27.228Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}