{"record":{"id":"73271bd4d41abc25","repo":"chroma-core/chroma","slug":"updating-key-is-not-supported-for-name","errorCode":null,"errorMessage":"Updating '${key}' is not supported for ${NAME}","messagePattern":"Updating '(.+?)' is not supported for (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"clients/new-js/packages/ai-embeddings/chroma-bm25/src/index.ts","lineNumber":270,"sourceCode":"        const config: ChromaBm25Config = {\n            k: this.k,\n            b: this.b,\n            avg_doc_length: this.avgDocLength,\n            token_max_length: this.tokenMaxLength,\n        };\n\n        if (this.customStopwords) {\n            config.stopwords = [...this.customStopwords];\n        }\n\n        return config;\n    }\n\n    public validateConfigUpdate(newConfig: Record<string, unknown>): void {\n        const mutableKeys = new Set([\"k\", \"b\", \"avg_doc_length\", \"token_max_length\", \"stopwords\"]);\n        for (const key of Object.keys(newConfig)) {\n            if (!mutableKeys.has(key)) {\n                throw new Error(`Updating '${key}' is not supported for ${NAME}`);\n            }\n        }\n    }\n\n    public static validateConfig(config: ChromaBm25Config): void {\n        validateConfigSchema(config, NAME);\n    }\n}\n\n// register with both name (chroma_bm25) and mapped package name (chroma-bm25)\nregisterSparseEmbeddingFunction(NAME, ChromaBm25EmbeddingFunction);\nregisterSparseEmbeddingFunction(\"chroma-bm25\", ChromaBm25EmbeddingFunction);\n","sourceCodeStart":252,"sourceCodeEnd":283,"githubUrl":"https://github.com/chroma-core/chroma/blob/aecdd12c8a891610db8653630b066b32ceb678b5/clients/new-js/packages/ai-embeddings/chroma-bm25/src/index.ts#L252-L283","documentation":"Thrown by ChromaBm25EmbeddingFunction.validateConfigUpdate when a config update payload contains any key outside the mutable set {k, b, avg_doc_length, token_max_length, stopwords}. BM25 is a stateless algorithm whose structural fields cannot be rebuilt from stored data, so Chroma restricts updates to the scoring parameters; any other key (immutable like a model, or simply unknown/typo'd) is rejected.","triggerScenarios":"Updating the sparse embedding function config with an unrecognized or immutable key, e.g. { model: ... } or a camelCase typo like { avgDocLength: 300 }; copy-pasting a full config object (including read-only fields) into an update call instead of only changed fields.","commonSituations":"Porting Python chromadb config-update code that passes whole config dicts; using camelCase keys instead of the snake_case config schema (avg_doc_length, token_max_length); attempting to change fields that must stay fixed for consistency with existing indexed data.","solutions":["Send only the mutable keys you actually want to change: k, b, avg_doc_length, token_max_length, stopwords.","Use snake_case exactly as listed (avg_doc_length, not avgDocLength).","If you need a fundamentally different configuration, create a new collection with a new embedding function instead of updating.","Log Object.keys(newConfig) before updating to spot stray/typo'd keys."],"exampleFix":"// before\nawait collection.modify({\n  embedding_function: { name: \"chroma_bm25\", config: { k: 1.5, model: \"bm25\" } }, // 'model' not mutable\n});\n\n// after\nawait collection.modify({\n  embedding_function: { name: \"chroma_bm25\", config: { k: 1.5 } },\n});","handlingStrategy":"validation","validationCode":"const BM25_MUTABLE = new Set([\"k\", \"b\", \"avg_doc_length\", \"token_max_length\", \"stopwords\"]);\nconst patch = { k: 1.5 }; // your intended changes\nconst illegal = Object.keys(patch).filter((k) => !BM25_MUTABLE.has(k));\nif (illegal.length > 0) {\n  throw new Error(`Non-updatable BM25 keys: ${illegal.join(\", \")}`);\n}\n// then perform the config update","typeGuard":"function isBm25MutableConfig(c: Record<string, unknown>): boolean {\n  return Object.keys(c).every((k) =>\n    [\"k\", \"b\", \"avg_doc_length\", \"token_max_length\", \"stopwords\"].includes(k),\n  );\n}","tryCatchPattern":null,"preventionTips":["Send only changed keys in update payloads, never full config snapshots.","Use snake_case field names (avg_doc_length, token_max_length).","Log Object.keys(payload) before updating to catch typos early."],"tags":["config","validation","bm25","sparse-embeddings"],"backgroundTag":"immutable-config-update","analyzedSha":"aecdd12c8a891610db8653630b066b32ceb678b5","analyzedAt":"2026-08-16T21:53:27.228Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}