chroma-core/chroma · error · ValueError

Invalid value for parameter {name}: {value}

Error message

Invalid value for parameter {name}: {value}

What it means

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.

Source

Thrown at chromadb/api/configuration.py:170

    def get_parameter(self, name: str) -> ConfigurationParameter:
        """Returns the parameter with the given name, or except if it doesn't exist."""
        if name not in self.parameter_map:
            raise ValueError(
                f"Invalid parameter name: {name} for configuration {self.__class__.__name__}"
            )
        param_value = cast(ConfigurationParameter, self.parameter_map.get(name))
        return param_value

    def set_parameter(self, name: str, value: Union[str, int, float, bool]) -> None:
        """Sets the parameter with the given name to the given value."""
        if name not in self.definitions:
            raise ValueError(f"Invalid parameter name: {name}")
        definition = self.definitions[name]
        parameter = self.parameter_map[name]
        if definition.is_static:
            raise StaticParameterError(f"Cannot set static parameter: {name}")
        if not definition.validator(value):
            raise ValueError(f"Invalid value for parameter {name}: {value}")
        parameter.value = value

    @override
    def to_json_str(self) -> str:
        """Returns the JSON representation of the configuration."""
        return json.dumps(self.to_json())

    @classmethod
    @override
    def from_json_str(cls, json_str: str) -> Self:
        """Returns a configuration from the given JSON string."""
        try:
            config_json = json.loads(json_str)
        except json.JSONDecodeError:
            raise ValueError(
                f"Unable to decode configuration from JSON string: {json_str}"
            )
        return cls.from_json(config_json) if config_json else cls()

View on GitHub (pinned to aecdd12c8a)

Solutions

  1. Validate before setting: run cfg.definitions[name].validator(value) and reject early with your own error message
  2. Coerce input types (int/float) and normalize enum strings before calling set_parameter
  3. Fall back to the documented default when user input is invalid instead of passing it through

Example fix

# before
cfg.set_parameter("num_threads", threads_from_env)   # "0" or -1 sneaks in
# after
value = int(threads_from_env)
if not cfg.definitions["num_threads"].validator(value):
    raise ValueError(f"num_threads={value} out of range")
cfg.set_parameter("num_threads", value)
Defensive patterns

Strategy: validation

Validate before calling

def checked_set(cfg, name, value):
    d = cfg.definitions[name]
    coerced = type(d.default_value)(value)
    if not d.validator(coerced):
        raise ValueError(f"{name}={value!r} rejected by validator")
    cfg.set_parameter(name, coerced)

Prevention

When it happens

Trigger: 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.

Common situations: 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).

Related errors


AI-assisted analysis of chroma-core/chroma@aecdd12c8a (2026-08-16). Data as JSON: /api/errors/7bbd455d037e1718. Report an issue: GitHub.