{"record":{"id":"0a39f436abd4e4ba","repo":"mudler/LocalAI","slug":"width-and-height-must-each-be-at-least-256","errorCode":null,"errorMessage":"width and height must each be at least 256","messagePattern":"width and height must each be at least 256","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"backend/python/longcat-video/longcat_utils.py","lineNumber":192,"sourceCode":"\n\ndef avatar_segments_for_frames(frames):\n    if not frames or frames <= 93:\n        return 1\n    return 1 + math.ceil((frames - 93) / 80)\n\n\ndef avatar_segments_for_duration(duration_seconds, fps=25):\n    if duration_seconds <= 0:\n        return 1\n    return avatar_segments_for_frames(math.ceil(duration_seconds * fps))\n\n\ndef validate_dimensions(width, height):\n    width = width or 832\n    height = height or 480\n    if width < 256 or height < 256:\n        raise ValueError(\"width and height must each be at least 256\")\n    if width > 1280 or height > 768:\n        raise ValueError(\"width and height must not exceed 1280x768\")\n    if width % 16 != 0 or height % 16 != 0:\n        raise ValueError(\"width and height must be divisible by 16\")\n    if width * height > 1280 * 768:\n        raise ValueError(\"requested video dimensions exceed the 1280x768 pixel limit\")\n    return width, height\n","sourceCodeStart":174,"sourceCodeEnd":200,"githubUrl":"https://github.com/mudler/LocalAI/blob/44413a9d06bf5bc52ce088ba8ca74e5a2e8bee26/backend/python/longcat-video/longcat_utils.py#L174-L200","documentation":"Raised by validate_dimensions() in longcat-video when either width or height is below 256px. Defaults are 832x480 when falsy, so this fires only when an explicit small value was passed. It is the first of four ordered checks (min size, max size, divisibility, pixel budget).","triggerScenarios":"Calling validate_dimensions(width, height) with width < 256 or height < 256, e.g. 128x720 thumbnails or 832x240 for a short video.","commonSituations":"Generating low-resolution previews/thumbnails, swapping width and height assumptions, or reusing image-generation dimensions (which allow smaller sizes) for the video pipeline.","solutions":["Set both dimensions to at least 256 (e.g. 256x256 minimum)","Pass 0/None/empty to fall back to the 832x480 default rather than an explicit tiny value","Scale up small source assets to >=256 before requesting generation"],"exampleFix":"# before\nvalidate_dimensions(192, 1080)  # ValueError: at least 256\n\n# after\nvalidate_dimensions(256, 1080)","handlingStrategy":"validation","validationCode":"def clean_dims(w, h):\n    w = w or 832\n    h = h or 480\n    if w < 256 or h < 256:\n        raise ValueError('each dimension must be >= 256')\n    return w, h\n\nw, h = clean_dims(request.width, request.height)\nvalidate_dimensions(w, h)","typeGuard":"def dims_ok(w: int, h: int) -> bool:\n    return (w or 832) >= 256 and (h or 480) >= 256","tryCatchPattern":"try:\n    w, h = validate_dimensions(request.width, request.height)\nexcept ValueError as err:\n    return error_response(str(err), hint='minimum 256x256; default 832x480')","preventionTips":["Enforce a 256px floor in the request UI","Pass empty/0 for defaults instead of tiny explicit values","Unit-test dimension guards at the boundaries 255/256"],"tags":["python","validation","dimensions","longcat-video"],"backgroundTag":null,"analyzedSha":"44413a9d06bf5bc52ce088ba8ca74e5a2e8bee26","analyzedAt":"2026-08-15T10:13:50.291Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}