{"record":{"id":"654b835cd31a79a5","repo":"invoke-ai/InvokeAI","slug":"unsupported-resize-mode-resize-mode","errorCode":null,"errorMessage":"Unsupported resize_mode: '{resize_mode}'.","messagePattern":"Unsupported resize_mode: '(.+?)'\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"invokeai/app/util/controlnet_utils.py","lineNumber":423,"sourceCode":"        nimage = nimage[None, :]\n        nimage = np.concatenate([nimage], axis=0)\n        # normalizing RGB values to [0,1] range (in PIL.Image they are [0-255])\n        nimage = np.array(nimage).astype(np.float32) / 255.0\n        nimage = nimage.transpose(0, 3, 1, 2)\n        timage = torch.from_numpy(nimage)\n\n    # use fancy lvmin controlnet resizing\n    elif resize_mode == \"just_resize\" or resize_mode == \"crop_resize\" or resize_mode == \"fill_resize\":\n        nimage = np.array(image)\n        timage, nimage = np_img_resize(\n            np_img=nimage,\n            resize_mode=resize_mode,\n            h=height,\n            w=width,\n            device=torch.device(device),\n        )\n    else:\n        raise ValueError(f\"Unsupported resize_mode: '{resize_mode}'.\")\n\n    if timage.shape[1] < num_channels or num_channels <= 0:\n        raise ValueError(f\"Cannot achieve the target of num_channels={num_channels}.\")\n    timage = timage[:, :num_channels, :, :]\n\n    timage = timage.to(device=device, dtype=dtype)\n    cfg_injection = control_mode == \"more_control\" or control_mode == \"unbalanced\"\n    if do_classifier_free_guidance and not cfg_injection:\n        timage = torch.cat([timage] * 2)\n    return timage\n","sourceCodeStart":405,"sourceCodeEnd":434,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/app/util/controlnet_utils.py#L405-L434","documentation":"prepare_control_image only supports the defined ResizeMode enum values (e.g. RESIZE, CROP, FIT, etc.); any other value reaches the final else branch and raises ValueError. The resize mode determines how the control image is resized/cropped to the target dimensions before inference.","triggerScenarios":"Calling prepare_control_image with a raw string or arbitrary int instead of a ResizeMode enum member, or a ResizeMode added in a newer version but passed through deserialization the code path doesn't handle.","commonSituations":"Old saved workflows/settings containing a resize_mode value removed or renamed across InvokeAI versions; API clients sending numeric codes; config files edited by hand.","solutions":["Pass a valid ResizeMode enum member (e.g. ResizeMode.RESIZE) instead of a raw string/int","Coerce incoming values: ResizeMode(value) in a try/except before calling, defaulting to ResizeMode.RESIZE","If upgrading, migrate saved workflows whose resize_mode values match the old enum naming"],"exampleFix":"// before\nprep_control_data(..., resize_mode=\"just_resize\", ...)\n// after\nfrom invokeai.app.invocations.constants import ResizeMode\nprep_control_data(..., resize_mode=ResizeMode.RESIZE, ...)  # or ResizeMode(value) validated","handlingStrategy":"validation","validationCode":"from invokeai.app.invocations.constants import ResizeMode\ndef coerce_resize_mode(v) -> ResizeMode:\n    try:\n        return ResizeMode(v)\n    except ValueError:\n        return ResizeMode.RESIZE","typeGuard":"def is_resize_mode(v: object) -> bool:\n    try:\n        ResizeMode(v)\n        return True\n    except ValueError:\n        return False","tryCatchPattern":"try:\n    image = prepare_control_image(..., resize_mode=resize_mode)\nexcept ValueError as e:\n    if \"Unsupported resize_mode\" in str(e):\n        image = prepare_control_image(..., resize_mode=ResizeMode.RESIZE)\n    else:\n        raise","preventionTips":["Always pass ResizeMode enum members, never raw strings or ints","Migrate legacy saved workflows after upgrading InvokeAI (enum renames)","Deserialize with pydantic using ResizeMode so invalid values fail early"],"tags":["controlnet","validation","enum"],"backgroundTag":"invalid-enum-value","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}