odysseus-dev/odysseus · error · HTTPException
detail[-4000:]
Error message
detail[-4000:]
What it means
This is not a fixed message: _run_bridge raises HTTPException(500, detail[-4000:]) when the MLX Swift bridge subprocess (odysseus-mlx-inpaint / mlx-lama-serve / odysseus-mlx-colorize / mlx-ddcolor-serve) exits non-zero. The detail is the last 4000 chars of the bridge's stderr (or stdout), also logged server-side, so the visible text is the underlying Swift/MLX failure.
Source
Thrown at scripts/mlx_image_server.py:211
img = Image.open(io.BytesIO(raw))
if img.mode == "RGBA":
# OpenAI edits mask convention: transparent = regenerate.
alpha = img.getchannel("A")
mask = alpha.point(lambda p: 255 if p < 128 else 0)
else:
mask = img.convert("L")
mask.save(out_path, format="PNG")
except Exception as e:
raise HTTPException(400, f"Invalid mask image: {e}") from e
def _run_bridge(cmd: list[str]) -> None:
env = os.environ.copy()
proc = subprocess.run(cmd, env=env, text=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
if proc.returncode != 0:
detail = (proc.stderr or proc.stdout or "MLX Swift bridge failed").strip()
logger.error("MLX Swift bridge failed (%s): %s\n%s", proc.returncode, " ".join(cmd), detail[-4000:])
raise HTTPException(500, detail[-4000:])
def _run_ddcolor_bridge(model: str, image_raw: bytes, out_path: Path) -> None:
bridge = _resolve_bridge(["odysseus-mlx-colorize", "mlx-ddcolor-serve"])
if not bridge:
raise _unsupported_swift_mlx_runtime(model)
with tempfile.TemporaryDirectory(prefix="odysseus-ddcolor-") as td:
inp = Path(td) / "input.png"
_write_bridge_input_image(image_raw, inp)
weights = _weights_path(model)
tier = "tiny" if "tiny" in model.lower() else "large"
_run_bridge([
bridge,
"--model", str(weights),
"--image", str(inp),
"--output", str(out_path),
"--tier", tier,
])View on GitHub (pinned to f9235ebbf1)
Solutions
- Read the embedded stderr tail (and server log line 'MLX Swift bridge failed') to identify the real cause
- Re-run with a smaller image (resize to e.g. 1024px max) if the tail shows a memory error
- Verify the bridge executable runs standalone with --help, and reinstall the MLX Swift package if it doesn't
- Ensure model weights resolved correctly (see errors 941/942) and are compatible with the bridge tier
Defensive patterns
Strategy: retry
Validate before calling
import shutil
bridge = shutil.which('odysseus-mlx-inpaint') or shutil.which('mlx-lama-serve')
assert bridge, 'MLX Swift bridge not installed' Try / catch
except HTTPException as e:
tail = e.detail[-500:]
if 'out of memory' in tail.lower():
shrink_image_to(1024); retry_once()
else:
surface_bridge_stderr(tail) Prevention
- Run the bridge standalone on a sample image before wiring clients
- Cap input image dimensions client-side
- Log the full bridge command on failure for reproducibility
When it happens
Trigger: Any /v1/images/edits or /v1/images/harmonize call on LaMa/MI-GAN/DDColor models where the bridge process fails: missing weights, out-of-memory, incompatible Swift toolchain, bad weights path, or unsupported image dimensions.
Common situations: First run before model weights are downloaded; macOS or Xcode/Swift version mismatch for the MLX Swift package; large input image exhausting unified memory; passing a safetensors file the bridge doesn't support; bridge binary half-installed after a partial pip/brew install.
Related errors
- MLX Swift bridge completed but did not write {out_path}
- No safetensors weights found for {model} in {snap}
- LaMa / MI-GAN inpainting requires an image mask. Use the edi
- HiDream generator script not found in snapshot: {script}
- Boogu MLX generation failed: {e}
AI-assisted analysis of odysseus-dev/odysseus@f9235ebbf1 (2026-08-14).
Data as JSON: /api/errors/063d4435b64de5f1.
Report an issue: GitHub.