{"record":{"id":"44e19cf8652c7b89","repo":"odysseus-dev/odysseus","slug":"mlx-image-generator-completed-but-did-not-write-o","errorCode":null,"errorMessage":"MLX image generator completed but did not write {out_path}","messagePattern":"MLX image generator completed but did not write (.+?)","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"scripts/mlx_image_server.py","lineNumber":380,"sourceCode":"                if _args.base_model:\n                    cmd += [\"--base-model\", _args.base_model]\n                if _args.lora_style:\n                    cmd += [\"--lora-style\", _args.lora_style]\n                if _args.lora_paths:\n                    cmd += [\"--lora-paths\", *_args.lora_paths]\n                lora_scales = _valid_numbers(_args.lora_scales)\n                if lora_scales:\n                    cmd += [\"--lora-scales\", *lora_scales]\n                if \"qwen\" not in model.lower():\n                    cmd += [\"--width\", str(width), \"--height\", str(height)]\n                env = os.environ.copy()\n                proc = subprocess.run(cmd, env=env, text=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)\n                if proc.returncode != 0:\n                    detail = (proc.stderr or proc.stdout or f\"{cli} failed\").strip()\n                    logger.error(\"MLX image command failed (%s): %s\\n%s\", proc.returncode, \" \".join(cmd), detail[-4000:])\n                    raise HTTPException(500, detail[-4000:])\n            if not out_path.exists():\n                raise HTTPException(500, f\"MLX image generator completed but did not write {out_path}\")\n            b64 = base64.b64encode(out_path.read_bytes()).decode(\"ascii\")\n            out_images.append({\"b64_json\": b64})\n    return {\"created\": 0, \"data\": out_images}\n\n\n@app.post(\"/v1/images/edits\")\nasync def edit_image(\n    image: UploadFile = File(...),\n    mask: UploadFile | None = File(None),\n    prompt: str = Form(\"\"),\n    model: str = Form(\"\"),\n    n: int = Form(1),\n    size: str = Form(\"1024x1024\"),\n    response_format: str = Form(\"b64_json\"),\n):\n    active_model = model or _args.model\n    if _is_lama_inpaint(active_model) or _is_ddcolor(active_model):\n        image_raw = await image.read()","sourceCodeStart":362,"sourceCodeEnd":398,"githubUrl":"https://github.com/odysseus-dev/odysseus/blob/f9235ebbf13f693a6fd29ce70b097f6ec83705bf/scripts/mlx_image_server.py#L362-L398","documentation":"Raised in /v1/images/generations of scripts/mlx_image_server.py with HTTP 500 when the generation subprocess (mflux CLI, HiDream script, or Boogu in-process call) reported success but the expected output file out_path (a temp dir image.png) was not created. It guards the contract that every backend must write the output path it was given.","triggerScenarios":"A backend exits 0 without producing the file: CLI wrote to a different location (output flag mishandled), HiDream script saved elsewhere or silently skipped saving, Boogu path failed to save without raising, or temp-dir permission issues.","commonSituations":"Version change in mflux/HiDream script renaming the --output semantics; quantized forks that print instead of save; sandboxed temp dirs cleaned mid-run; disk-full so the save silently no-ops in the child.","solutions":["Reproduce the exact logged command manually and check where output lands","Upgrade/align the backend version with what the server expects for --output","Freeze/inspect the temp dir (replace TemporaryDirectory with a kept dir) to see whether the file appears then vanishes","Check disk space and temp dir permissions on the host"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"# server-side guard: verify backend writes before accepting traffic\nsubprocess.run([cli, '--model', m, '--prompt', 'smoke', '--steps', '1', '--output', '/tmp/probe.png'], check=True)\nassert pathlib.Path('/tmp/probe.png').exists()","typeGuard":null,"tryCatchPattern":"try:\n    gen_and_read(out_path)\nexcept HTTPException as e:\n    if 'did not write' in str(e.detail):\n        out_path = run_backend_manually_and_locate_output()  # fallback path\n    else:\n        raise","preventionTips":["Pin backend CLI versions; --output semantics drift across releases","Add a post-boot smoke generation to the server healthcheck","Watch mflux/HiDream changelogs for output-flag changes"],"tags":["mflux","hidream","subprocess","contract","http-500"],"backgroundTag":null,"analyzedSha":"f9235ebbf13f693a6fd29ce70b097f6ec83705bf","analyzedAt":"2026-08-14T21:47:48.359Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}