{"record":{"id":"cae40b9e01a198cd","repo":"odysseus-dev/odysseus","slug":"invalid-image","errorCode":null,"errorMessage":"Invalid image","messagePattern":"Invalid image","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"routes/gallery/gallery_routes.py","lineNumber":49,"sourceCode":"\n_SAM_STATE: Dict[str, Any] = {}\n_GROUNDING_STATE: Dict[str, Any] = {}\n\n\ndef _b64_to_pil_image(image_b64: str, *, mode: str = \"RGBA\"):\n    if not image_b64:\n        raise HTTPException(400, \"Missing image\")\n    if \",\" in image_b64 and image_b64.split(\",\", 1)[0].startswith(\"data:\"):\n        image_b64 = image_b64.split(\",\", 1)[1]\n    try:\n        from PIL import Image\n\n        raw = base64.b64decode(image_b64)\n        return Image.open(io.BytesIO(raw)).convert(mode)\n    except HTTPException:\n        raise\n    except Exception as exc:\n        raise HTTPException(400, \"Invalid image\") from exc\n\n\ndef _pil_image_to_b64(img, *, fmt: str = \"PNG\") -> str:\n    buf = io.BytesIO()\n    img.save(buf, format=fmt)\n    return base64.b64encode(buf.getvalue()).decode(\"ascii\")\n\n\ndef _load_sam_backend():\n    model_id = os.getenv(\"ODYSSEUS_SAM_MODEL\", \"facebook/sam-vit-base\")\n    cached = _SAM_STATE.get(model_id)\n    if cached:\n        return cached\n    try:\n        import torch\n        from transformers import SamModel, SamProcessor\n    except Exception as exc:\n        raise HTTPException(","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/odysseus-dev/odysseus/blob/f9235ebbf13f693a6fd29ce70b097f6ec83705bf/routes/gallery/gallery_routes.py#L31-L67","documentation":"Error \"Invalid image\" 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":["Send a valid, decodable image in a supported format (PNG/JPEG).","Re-export or re-upload the image if it is corrupted."],"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"}