{"record":{"id":"cf47d95337ddc12e","repo":"invoke-ai/InvokeAI","slug":"initial-latents-are-required-when-using-an-inpaint","errorCode":null,"errorMessage":"Initial latents are required when using an inpaint mask (image-to-image inpainting)","messagePattern":"Initial latents are required when using an inpaint mask \\(image-to-image inpainting\\)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"invokeai/app/invocations/anima_denoise.py","lineNumber":640,"sourceCode":"                s_0 = sigmas[0]\n                latents = s_0 * noise + (1.0 - s_0) * init_latents\n            else:\n                latents = init_latents\n        else:\n            if self.denoising_start > 1e-5:\n                raise ValueError(\"denoising_start should be 0 when initial latents are not provided.\")\n            assert noise is not None\n            latents = noise\n\n        if total_steps <= 0:\n            return latents.squeeze(2)\n\n        # Prepare inpaint extension\n        inpaint_mask = self._prep_inpaint_mask(context, latents.squeeze(2))\n        inpaint_extension: AnimaInpaintExtension | None = None\n        if inpaint_mask is not None:\n            if init_latents is None:\n                raise ValueError(\"Initial latents are required when using an inpaint mask (image-to-image inpainting)\")\n            assert noise is not None\n            inpaint_extension = AnimaInpaintExtension(\n                init_latents=init_latents.squeeze(2),\n                inpaint_mask=inpaint_mask,\n                noise=noise.squeeze(2),\n                shift=ANIMA_SHIFT,\n            )\n\n        step_callback = self._build_step_callback(context)\n\n        # Initialize scheduler driver if not using built-in Euler.\n        use_scheduler = self.scheduler != \"euler\"\n        driver: AnimaSchedulerDriver | None = None\n        if use_scheduler:\n            driver = AnimaSchedulerDriver(\n                scheduler_name=self.scheduler,\n                sigmas=sigmas,\n                steps=self.steps,","sourceCodeStart":622,"sourceCodeEnd":658,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/app/invocations/anima_denoise.py#L622-L658","documentation":"An inpaint mask requires the original image's latents so the extension can composite inpainted regions back against known content. If a mask is present but init_latents is None, InvokeAI raises this ValueError because inpainting is impossible without reference latents.","triggerScenarios":"Supplying an inpaint_mask to the Anima denoise invocation (mask detected by _prep_inpaint_mask) while running in pure txt2img mode with no initial latents.","commonSituations":"Using a canvas/mask workflow where the init image layer was removed or never rendered; thinking a mask alone is enough for inpainting; converting an img2img inpaint workflow to txt2img but keeping the mask.","solutions":["Provide an init image so init_latents can be encoded (img2img inpainting).","Remove or disconnect the inpaint mask if you truly want unconditional txt2img generation.","Verify upstream nodes actually emit the init image/latents into the denoise node."],"exampleFix":"// before\ndenoise.mask = mask_field  # no image input\n// after\ndenoise.image = init_image_field  # img2img inpainting\n// or remove the mask for txt2img","handlingStrategy":"validation","validationCode":"if inpaint_mask is not None and init_latents is None:\n    raise ValueError(\"Inpainting requires an init image/latents\")","typeGuard":null,"tryCatchPattern":"try:\n    output = invoker.invoke(denoise_invocation)\nexcept ValueError as e:\n    if \"inpaint mask\" in str(e):\n        raise RuntimeError(\"Connect an init image or remove the mask before running\") from e","preventionTips":["Require an image input whenever a mask is present in the workflow","Disable mask nodes in pure txt2img graphs","Validate graph edges (mask present => image edge present) before submission"],"tags":["validation","inpainting","latents"],"backgroundTag":"missing-required-input","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}