{"record":{"id":"e2610cf8b73260d7","repo":"mudler/LocalAI","slug":"name-must-be-at-most-maximum","errorCode":null,"errorMessage":"{name} must be at most {maximum}","messagePattern":"(.+?) must be at most (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"backend/python/longcat-video/longcat_utils.py","lineNumber":101,"sourceCode":"\n\ndef require_bool(value, name):\n    if isinstance(value, bool):\n        return value\n    if isinstance(value, str) and value.lower() in {\"true\", \"false\"}:\n        return value.lower() == \"true\"\n    raise ValueError(f\"{name} must be true or false\")\n\n\ndef require_int(value, name, minimum=None, maximum=None):\n    try:\n        parsed = int(value)\n    except (TypeError, ValueError) as err:\n        raise ValueError(f\"{name} must be an integer\") from err\n    if minimum is not None and parsed < minimum:\n        raise ValueError(f\"{name} must be at least {minimum}\")\n    if maximum is not None and parsed > maximum:\n        raise ValueError(f\"{name} must be at most {maximum}\")\n    return parsed\n\n\ndef require_float(value, name, minimum=None, maximum=None):\n    try:\n        parsed = float(value)\n    except (TypeError, ValueError) as err:\n        raise ValueError(f\"{name} must be a number\") from err\n    if minimum is not None and parsed < minimum:\n        raise ValueError(f\"{name} must be at least {minimum}\")\n    if maximum is not None and parsed > maximum:\n        raise ValueError(f\"{name} must be at most {maximum}\")\n    return parsed\n\n\ndef attention_overrides(name):\n    try:\n        return dict(ATTENTION_OVERRIDES[name])","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/mudler/LocalAI/blob/44413a9d06bf5bc52ce088ba8ca74e5a2e8bee26/backend/python/longcat-video/longcat_utils.py#L83-L119","documentation":"Raised by require_int() in longcat-video when the parsed integer exceeds the maximum bound the option declares. The value is a valid integer but outside the supported upper range for that parameter.","triggerScenarios":"Calling require_int(value, name, maximum=N) with a parsed value above N, e.g. require_int(9999, 'num_frames', maximum=201) or duration-derived frame counts exceeding the cap.","commonSituations":"Requesting longer videos or higher frame counts than the model supports, or computing segments from a duration that balloons past the limit.","solutions":["Lower the value to within the documented maximum","If the hardware/model genuinely supports more, raise the maximum at the call site that enforces it","Split the request into multiple smaller requests when the cap is a hard model limit"],"exampleFix":"# before\nframes = require_int(400, 'num_frames', maximum=201)  # ValueError\n\n# after\nframes = require_int(201, 'num_frames', maximum=201)","handlingStrategy":"validation","validationCode":"MAX = 201\nraw = min(int(request.num_frames), MAX)  # clamp, or reject\nframes = require_int(raw, 'num_frames', maximum=MAX)","typeGuard":"def is_at_most(v, maximum: int) -> bool:\n    try:\n        return int(v) <= maximum\n    except (TypeError, ValueError):\n        return False","tryCatchPattern":"try:\n    frames = require_int(raw, 'num_frames', maximum=201)\nexcept ValueError as err:\n    return error_response(str(err), hint=f'num_frames must be <= 201, got {raw!r}')","preventionTips":["Cap request parameters at the API gateway","Expose the documented maximum in client docs/UI limits","Split oversized jobs instead of raising limits silently"],"tags":["python","validation","range-check","longcat-video"],"backgroundTag":null,"analyzedSha":"44413a9d06bf5bc52ce088ba8ca74e5a2e8bee26","analyzedAt":"2026-08-15T10:13:50.291Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}