mudler/LocalAI · error · ValueError

{name} must be true or false

Error message

{name} must be true or false

What it means

ValueError from require_bool() in longcat_utils.py: model/request option values that are supposed to be boolean must be either an actual Python bool or the strings 'true'/'false' (case-insensitive). Anything else — '1', 'yes', 0, None, 'True ' with odd casing is fine but 'TRUE ' with whitespace, 'on', integers — is rejected with '{name} must be true or false', where name identifies the offending option (e.g. use_distill, use_int8).

Source

Thrown at backend/python/longcat-video/longcat_utils.py:90

    LocalAI injects serving defaults (e.g. the llama.cpp cache_reuse / parallel
    options) onto every model config regardless of backend. A backend should
    tolerate options it does not understand rather than refuse to load, matching
    the other LocalAI Python backends; the caller logs the ignored keys.

    Returns (kept, ignored) where kept preserves the known entries and ignored is
    the sorted list of dropped keys.
    """
    ignored = sorted(key for key in options if key not in known)
    kept = {key: value for key, value in options.items() if key in known}
    return kept, ignored


def require_bool(value, name):
    if isinstance(value, bool):
        return value
    if isinstance(value, str) and value.lower() in {"true", "false"}:
        return value.lower() == "true"
    raise ValueError(f"{name} must be true or false")


def require_int(value, name, minimum=None, maximum=None):
    try:
        parsed = int(value)
    except (TypeError, ValueError) as err:
        raise ValueError(f"{name} must be an integer") from err
    if minimum is not None and parsed < minimum:
        raise ValueError(f"{name} must be at least {minimum}")
    if maximum is not None and parsed > maximum:
        raise ValueError(f"{name} must be at most {maximum}")
    return parsed


def require_float(value, name, minimum=None, maximum=None):
    try:
        parsed = float(value)
    except (TypeError, ValueError) as err:

View on GitHub (pinned to 44413a9d06)

Solutions

  1. Use literal true/false booleans in YAML/model options (they parse to Python bool)
  2. If values come from string sources, normalize to 'true'/'false' (lowercased, trimmed) before passing
  3. Identify the offending option from the name in the message and fix just that key

Example fix

# before
options:
  use_distill: 1
  use_int8: "yes"

# after
options:
  use_distill: true
  use_int8: false
Defensive patterns

Strategy: validation

Validate before calling

def coerce_bool(value, name: str) -> bool:
    if isinstance(value, bool):
        return value
    if isinstance(value, str) and value.strip().lower() in {"true", "false"}:
        return value.strip().lower() == "true"
    raise ValueError(f"{name} must be true or false, got {value!r}")

options = {k: coerce_bool(v, k) if k in BOOL_KEYS else v for k, v in options.items()}

Type guard

def is_bool_like(value) -> bool:
    return isinstance(value, bool) or (isinstance(value, str) and value.strip().lower() in {"true", "false"})

Try / catch

try:
    stub.LoadModel(opts)
except grpc.RpcError as e:
    if "must be true or false" in (e.details() or ""):
        name = e.details().split()[0]  # offending option name
        opts["options"][name] = bool(opts["options"][name])  # coerce and retry
        stub.LoadModel(opts)
    else:
        raise

Prevention

When it happens

Trigger: Setting use_int8: 1 or use_distill: "yes" in YAML model options; passing 0/1 ints from generated config tooling; values like 'on'/'off' from environment-style config.

Common situations: YAML auto-parses yes/no to bool (fine) but JSON configs with 1/0 integers; templates rendering booleans as strings like 'True' works, but 'true ' with trailing whitespace or 'enabled' fails.

Related errors


AI-assisted analysis of mudler/LocalAI@44413a9d06 (2026-08-15). Data as JSON: /api/errors/34a13c878c967964. Report an issue: GitHub.