{"record":{"id":"131cdea0935b6c82","repo":"chroma-core/chroma","slug":"not-a-valid-hnsw-config-e","errorCode":null,"errorMessage":"not a valid hnsw config: {e}","messagePattern":"not a valid hnsw config: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"info","filePath":"chromadb/api/collection_configuration.py","lineNumber":146,"sourceCode":"        try:\n            hnsw_config = config.get_parameter(\"hnsw\").value\n        except ValueError:\n            hnsw_config = None\n        try:\n            spann_config = config.get_parameter(\"spann\").value\n        except ValueError:\n            spann_config = None\n        try:\n            ef = config.get_parameter(\"embedding_function\").value\n        except ValueError:\n            ef = None\n\n    ef_config: Dict[str, Any] | None = None\n    if hnsw_config is not None:\n        try:\n            hnsw_config = cast(HNSWConfiguration, hnsw_config)\n        except Exception as e:\n            raise ValueError(f\"not a valid hnsw config: {e}\")\n    if spann_config is not None:\n        try:\n            spann_config = cast(SpannConfiguration, spann_config)\n        except Exception as e:\n            raise ValueError(f\"not a valid spann config: {e}\")\n\n    if ef is None:\n        ef = None\n        ef_config = {\"type\": \"legacy\"}\n\n    if ef is not None:\n        try:\n            if ef.is_legacy():\n                ef_config = {\"type\": \"legacy\"}\n            else:\n                ef_config = {\n                    \"name\": ef.name(),\n                    \"type\": \"known\",","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/chroma-core/chroma/blob/aecdd12c8a891610db8653630b066b32ceb678b5/chromadb/api/collection_configuration.py#L128-L164","documentation":"In collection_configuration_to_json(), the value stored under 'hnsw' is passed through typing.cast(HNSWConfiguration, ...) inside a try/except that would raise this ValueError. typing.cast is a runtime no-op that never raises, so this except branch is unreachable in the current code — the error cannot actually be thrown. Its intent was to reject an hnsw configuration that is not a valid HNSW configuration dict.","triggerScenarios":"None at runtime — typing.cast never raises, so the except never fires. It would only matter if a fork replaced the cast with real validation.","commonSituations":"Developers encounter this string while grepping sources or in static analysis and assume hnsw config validation happens here; in reality malformed hnsw dicts are not caught by this branch.","solutions":["No action needed — the branch is dead code and cannot raise.","If you maintain a fork and want real enforcement, validate the dict's keys against CreateHNSWConfiguration fields yourself before serializing."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"HNSW_KEYS = {\"space\", \"ef_construction\", \"max_neighbors\", \"ef_search\", \"num_threads\", \"batch_size\", \"sync_threshold\", \"resize_factor\"}\n\ndef valid_hnsw_dict(cfg: dict) -> bool:\n    return isinstance(cfg, dict) and set(cfg) <= HNSW_KEYS","typeGuard":null,"tryCatchPattern":null,"preventionTips":["No guard needed: the raise site is unreachable (typing.cast never throws).","If maintaining a fork, replace the cast with real key validation before relying on this error."],"tags":["chroma","collection-configuration","hnsw","dead-code","vector-index"],"backgroundTag":"config-validation-failed","analyzedSha":"aecdd12c8a891610db8653630b066b32ceb678b5","analyzedAt":"2026-08-16T21:53:27.228Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}