{"record":{"id":"22730c7eb92afa6c","repo":"odysseus-dev/odysseus","slug":"failed-to-prepare-inpaint-request","errorCode":null,"errorMessage":"Failed to prepare inpaint request","messagePattern":"Failed to prepare inpaint request","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"routes/gallery/gallery_routes.py","lineNumber":1346,"sourceCode":"                # Build OpenAI mask: RGBA where alpha=255 means keep, 0 means regenerate.\n                # SD mask: white (255) = regenerate → alpha 0.  Black (0) = keep → alpha 255.\n                # RGB must be white for keep areas; start from fully-white opaque and\n                # overwrite alpha so visual contents match the expected semantic.\n                alpha = mask_png.point(lambda p: 255 - p)\n                oa_mask = Image.new(\"RGBA\", source_png.size, (255, 255, 255, 255))\n                oa_mask.putalpha(alpha)\n\n                src_buf = io.BytesIO()\n                source_png.save(src_buf, format=\"PNG\")\n                src_buf.seek(0)\n                mask_buf = io.BytesIO()\n                oa_mask.save(mask_buf, format=\"PNG\")\n                mask_buf.seek(0)\n            except HTTPException:\n                raise\n            except Exception:\n                logger.exception(\"inpaint_proxy: failed to prepare OpenAI request\")\n                raise HTTPException(400, \"Failed to prepare inpaint request\")\n\n            width = int(body.get(\"width\") or 1024)\n            height = int(body.get(\"height\") or 1024)\n            # gpt-image-1 only accepts 1024x1024, 1024x1536, 1536x1024 (no 'auto'\n            # for edits). Pick the closest to preserve aspect, default square.\n            if width > height * 1.15:\n                size = \"1536x1024\"\n            elif height > width * 1.15:\n                size = \"1024x1536\"\n            else:\n                size = \"1024x1024\"\n\n            files = {\n                \"image\": (\"source.png\", src_buf.getvalue(), \"image/png\"),\n                \"mask\": (\"mask.png\", mask_buf.getvalue(), \"image/png\"),\n            }\n            # Honor explicit model selection from the editor; fall back to gpt-image-1.\n            # dall-e-3 has no edit endpoint — refuse it loudly so the user picks again.","sourceCodeStart":1328,"sourceCodeEnd":1364,"githubUrl":"https://github.com/odysseus-dev/odysseus/blob/f9235ebbf13f693a6fd29ce70b097f6ec83705bf/routes/gallery/gallery_routes.py#L1328-L1364","documentation":"Error \"Failed to prepare inpaint request\" thrown in odysseus-dev/odysseus.","triggerScenarios":"Triggered when the corresponding server-side validation or runtime check at the recorded location rejects the request or operation and returns this error message to the caller.","commonSituations":"See trigger scenarios.","solutions":["Retry with a smaller image or mask; check server logs for details.","Verify the image and mask decode correctly before sending."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"f9235ebbf13f693a6fd29ce70b097f6ec83705bf","analyzedAt":"2026-08-14T21:47:48.359Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}