{"record":{"id":"7db81885d4eb0284","repo":"odysseus-dev/odysseus","slug":"image-not-found-7db818","errorCode":null,"errorMessage":"Image not found","messagePattern":"Image not found","errorType":"http","errorClass":"HTTPException","httpStatus":404,"severity":"error","filePath":"routes/gallery/gallery_routes.py","lineNumber":442,"sourceCode":"            ))\n            db.commit()\n            resp = {\"ok\": True, \"filename\": filename, \"id\": img_id}\n            if exif.get(\"exif_error\"):\n                resp[\"exif_warning\"] = exif[\"exif_error\"]\n            return resp\n        finally:\n            db.close()\n\n    # ---- POST /api/gallery/{id}/replace ----\n    @router.post(\"/api/gallery/{image_id}/replace\")\n    async def gallery_replace(request: Request, image_id: str):\n        \"\"\"Replace an existing gallery image file with a new one.\"\"\"\n        user = get_current_user(request)\n        db = SessionLocal()\n        try:\n            img = db.query(GalleryImage).filter(GalleryImage.id == image_id).first()\n            if not img:\n                raise HTTPException(404, \"Image not found\")\n            if not user or img.owner != user:\n                raise HTTPException(403, \"Not your image\")\n\n            form = await request.form()\n            file = form.get(\"image\")\n            if not file or not hasattr(file, 'read'):\n                raise HTTPException(400, \"No image provided\")\n\n            content = await read_upload_limited(file, GALLERY_UPLOAD_MAX_BYTES, \"Gallery replacement\")\n            GALLERY_IMAGE_DIR.mkdir(parents=True, exist_ok=True)\n            img_path = _gallery_image_path(img.filename)\n            img_path.write_bytes(content)\n\n            # Refresh dimensions in case the editor resized the canvas.\n            # updated_at auto-bumps via TimestampMixin's onupdate hook.\n            try:\n                from PIL import Image\n                from io import BytesIO","sourceCodeStart":424,"sourceCodeEnd":460,"githubUrl":"https://github.com/odysseus-dev/odysseus/blob/f9235ebbf13f693a6fd29ce70b097f6ec83705bf/routes/gallery/gallery_routes.py#L424-L460","documentation":"Error \"Image not found\" 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":["Refresh the gallery; the image may have been deleted.","Verify the image id is correct."],"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"}