mudler/LocalAI · error · ValueError
{name} must be an integer
Error message
{name} must be an integer What it means
Raised by require_int() in the longcat-video backend when a value passed as an integer option cannot be parsed with int(). Both TypeError (None, list, dict) and ValueError (non-numeric string like 'abc' or '1.5') are converted into this clearer ValueError, chained from the original exception.
Source
Thrown at backend/python/longcat-video/longcat_utils.py:97
"""
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:
raise ValueError(f"{name} must be a number") 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
View on GitHub (pinned to 44413a9d06)
Solutions
- Pass a real int, or a string that int() accepts exactly (e.g. '480' not '480.0')
- If the value is optional, ensure the caller maps None/omitted to the backend default before calling require_int instead of passing it through
- Convert floats first: require_int(int(float(value)), name) when fractional input is legitimate
Example fix
# before
require_int('480.0', 'width') # ValueError: width must be an integer
# after
require_int(int(float('480.0')), 'width') # 480 Defensive patterns
Strategy: validation
Validate before calling
def coerce_int(value, default=None):
if value is None:
return default
try:
return int(value)
except (TypeError, ValueError):
return None
width = coerce_int(opts.get('width'), 832)
if width is None:
raise ValueError('width must be an integer') from None Type guard
def is_int_like(v) -> bool:
if isinstance(v, bool):
return False
if isinstance(v, int):
return True
if isinstance(v, str):
try:
int(v)
return True
except ValueError:
return False
return False Try / catch
try:
value = require_int(raw, 'name')
except ValueError as err:
logger.warning('invalid option: %s', err)
value = DEFAULT Prevention
- Always convert/verify int-ability before passing user-supplied options
- Reject float strings early or normalize them with int(float(v))
- Treat None as 'use default' at the API boundary, never forward it
When it happens
Trigger: Calling a longcat-video backend option setter that routes through require_int with a non-integer value, e.g. width='832px', num_frames=None, or duration='long'. int('1.5') and int('') also fail, so float strings and empty strings trigger it even though they look numeric.
Common situations: YAML model config where a quoted value ('"480"' style strings work, '"480.0"' does not), env-var-sourced options that arrive as empty strings, or a JSON request body sending null for an optional integer field.
Related errors
- resolution must be 480p or 720p
- base_model must point to a LongCat-Video checkpoint
- request needs {segments} avatar segments, but max_segments i
- {name} must be true or false
- {name} must be a number
AI-assisted analysis of mudler/LocalAI@44413a9d06 (2026-08-15).
Data as JSON: /api/errors/85c6967a5c7aea58.
Report an issue: GitHub.