{"record":{"id":"bad8434ae1ad859c","repo":"invoke-ai/InvokeAI","slug":"source-dimensions-must-be-positive","errorCode":null,"errorMessage":"Source dimensions must be positive.","messagePattern":"Source dimensions must be positive\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"invokeai/app/invocations/wan_ideal_dimensions.py","lineNumber":62,"sourceCode":"}\n\n\ndef _scale_and_snap(\n    width: int,\n    height: int,\n    target_short_side: int,\n    rounding: WanRounding,\n    multiple: int,\n) -> tuple[int, int]:\n    \"\"\"Scale a source W×H so its shorter side equals ``target_short_side``, then\n    snap each dimension to ``multiple`` using the requested rounding mode.\n\n    ``multiple`` is the Wan pixel-grid constraint (16 for the 8x-VAE I2V/T2V\n    models, 32 for the 16x-VAE TI2V-5B). Shared by both ideal-dimensions nodes.\n    \"\"\"\n    short = min(width, height)\n    if short <= 0:\n        raise ValueError(\"Source dimensions must be positive.\")\n\n    # Reject sources so narrow that the scaled long side is still under one Wan\n    # pixel grid. The downstream clamp to ``max(w, multiple)`` would otherwise\n    # silently return multiple×multiple, which has no relation to the requested\n    # aspect ratio — better to fail fast and have the workflow author fix inputs.\n    long_side = max(width, height)\n    if long_side < multiple:\n        raise ValueError(\n            f\"Source longer side ({long_side}px) is smaller than the Wan pixel grid ({multiple}px). \"\n            f\"Use an input image at least {multiple}px on its longer side.\"\n        )\n\n    scale = target_short_side / short\n    raw_w = width * scale\n    raw_h = height * scale\n\n    if rounding == \"floor\":\n        w = int(raw_w // multiple) * multiple","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/app/invocations/wan_ideal_dimensions.py#L44-L80","documentation":"The Wan ideal-dimensions helper computes a scaled/snapped output size from a source image, and requires positive width and height. A zero or negative dimension would break the aspect-ratio math (division by zero or non-positive scaling), so it fails fast with this ValueError.","triggerScenarios":"Passing width=0, height=0, or negative values into a Wan Ideal Dimensions node's width/height inputs; upstream nodes emitting empty/invalid dimensions (e.g., an image metadata read that returned 0).","commonSituations":"Wired-from-metadata workflows where the source image has no stored dimensions; typos or invalid workflow JSON with 0-valued dimension fields.","solutions":["Provide a valid source image with positive width and height","Fix the width/height input values on the ideal-dimensions node (must be > 0)","Check the upstream node producing dimensions for a failed/empty metadata read"],"exampleFix":"// before\nidealDims: width=0, height=1080\n// after\nidealDims: width=1920, height=1080","handlingStrategy":"validation","validationCode":"if width <= 0 or height <= 0:\n    raise ValueError(f\"invalid source dimensions {width}x{height}\")","typeGuard":"def has_valid_dimensions(img) -> bool:\n    return img.width > 0 and img.height > 0","tryCatchPattern":"try:\n    dims = ideal_dims.invoke(context)\nexcept ValueError as e:\n    if 'dimensions must be positive' in str(e):\n        fix_or_reload_source_image()\n    else:\n        raise","preventionTips":["Validate source images load with real dimensions before wiring","Avoid hardcoded 0 values in workflow JSON dimension fields","Check upstream metadata readers for empty results"],"tags":["invokeai","wan","invalid-input","dimensions"],"backgroundTag":"invalid-parameter-value","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}