{"record":{"id":"7bbd455d037e1718","repo":"chroma-core/chroma","slug":"invalid-value-for-parameter-name-value","errorCode":null,"errorMessage":"Invalid value for parameter {name}: {value}","messagePattern":"Invalid value for parameter (.+?): (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"chromadb/api/configuration.py","lineNumber":170,"sourceCode":"    def get_parameter(self, name: str) -> ConfigurationParameter:\n        \"\"\"Returns the parameter with the given name, or except if it doesn't exist.\"\"\"\n        if name not in self.parameter_map:\n            raise ValueError(\n                f\"Invalid parameter name: {name} for configuration {self.__class__.__name__}\"\n            )\n        param_value = cast(ConfigurationParameter, self.parameter_map.get(name))\n        return param_value\n\n    def set_parameter(self, name: str, value: Union[str, int, float, bool]) -> None:\n        \"\"\"Sets the parameter with the given name to the given value.\"\"\"\n        if name not in self.definitions:\n            raise ValueError(f\"Invalid parameter name: {name}\")\n        definition = self.definitions[name]\n        parameter = self.parameter_map[name]\n        if definition.is_static:\n            raise StaticParameterError(f\"Cannot set static parameter: {name}\")\n        if not definition.validator(value):\n            raise ValueError(f\"Invalid value for parameter {name}: {value}\")\n        parameter.value = value\n\n    @override\n    def to_json_str(self) -> str:\n        \"\"\"Returns the JSON representation of the configuration.\"\"\"\n        return json.dumps(self.to_json())\n\n    @classmethod\n    @override\n    def from_json_str(cls, json_str: str) -> Self:\n        \"\"\"Returns a configuration from the given JSON string.\"\"\"\n        try:\n            config_json = json.loads(json_str)\n        except json.JSONDecodeError:\n            raise ValueError(\n                f\"Unable to decode configuration from JSON string: {json_str}\"\n            )\n        return cls.from_json(config_json) if config_json else cls()","sourceCodeStart":152,"sourceCodeEnd":188,"githubUrl":"https://github.com/chroma-core/chroma/blob/aecdd12c8a891610db8653630b066b32ceb678b5/chromadb/api/configuration.py#L152-L188","documentation":"ConfigurationInternal.set_parameter (chromadb/api/configuration.py:170) raises this ValueError when the new value passes the name and static checks but fails the definition's validator. At set time only the semantic validator runs (the constructor's type check does not), so this specifically reports values that are malformed for the parameter's domain - out-of-range numbers or strings outside the allowed set.","triggerScenarios":"set_parameter(\"num_threads\", 0) or a negative value where the validator requires positive ints; set_parameter(\"space\", \"euclidian\") with a typo outside the allowed distance functions; applying values parsed as strings from user input.","commonSituations":"Config hot-reload features pushing unvalidated user input into set_parameter; boundary values (0, -1) used as sentinels; typos in enum-like values (space function names).","solutions":["Validate before setting: run cfg.definitions[name].validator(value) and reject early with your own error message","Coerce input types (int/float) and normalize enum strings before calling set_parameter","Fall back to the documented default when user input is invalid instead of passing it through"],"exampleFix":"# before\ncfg.set_parameter(\"num_threads\", threads_from_env)   # \"0\" or -1 sneaks in\n# after\nvalue = int(threads_from_env)\nif not cfg.definitions[\"num_threads\"].validator(value):\n    raise ValueError(f\"num_threads={value} out of range\")\ncfg.set_parameter(\"num_threads\", value)","handlingStrategy":"validation","validationCode":"def checked_set(cfg, name, value):\n    d = cfg.definitions[name]\n    coerced = type(d.default_value)(value)\n    if not d.validator(coerced):\n        raise ValueError(f\"{name}={value!r} rejected by validator\")\n    cfg.set_parameter(name, coerced)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Coerce and validator-check values before set_parameter","Normalize enum-like strings (e.g. space function) against the allowed set","Reject boundary sentinels (0, -1) from user input early"],"tags":["chromadb","configuration","value-validation","mutation"],"backgroundTag":"configuration-validation-failed","analyzedSha":"aecdd12c8a891610db8653630b066b32ceb678b5","analyzedAt":"2026-08-16T21:53:27.228Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}