odysseus-dev/odysseus · error · HTTPException

Image file not found

Error message

Image file not found

What it means

404 guard for the 'gallery' branch of _load_odysseus_attachment_source: the gallery image row was found but its file on disk under generated_images is missing or not a regular file — the DB entry is stale relative to the filesystem. Attachment staging cannot proceed without the actual image bytes.

Solutions

  1. The image record exists but its file is missing on disk; restore it from backup or re-upload.
  2. Check storage paths and permissions for the gallery directory.
Defensive patterns

Strategy: validation

When it happens

Trigger: 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.

Common situations: See trigger scenarios.


AI-assisted analysis of odysseus-dev/odysseus@f9235ebbf1 (2026-08-14). Data as JSON: /api/errors/83f2c70c73e0268d. Report an issue: GitHub.

Appendix: source

Thrown at routes/email_routes.py:4110

                "csv": "csv",
                "xml": "xml",
                "text": "txt",
            }.get(lang, "txt")
            base = _safe_compose_filename(doc.title or "document", "document")
            if not base.lower().endswith(f".{ext}"):
                base = f"{base}.{ext}"
            return {"filename": base, "content": (doc.current_content or "").encode("utf-8")}

        if kind == "gallery":
            img = db.query(_GI).filter(_GI.id == item_id, _GI.is_active == True).first()
            if not img:
                raise HTTPException(status_code=404, detail="Image not found")
            if owner and img.owner and img.owner != owner:
                raise HTTPException(status_code=404, detail="Image not found")
            from routes.gallery.gallery_routes import _gallery_image_path
            src = _gallery_image_path(img.filename)
            if not src.exists() or not src.is_file():
                raise HTTPException(status_code=404, detail="Image file not found")
            return {"filename": _safe_compose_filename(img.filename or "gallery-image.png"), "path": src}

        raise HTTPException(status_code=400, detail="Unknown attachment kind")

    @router.post("/compose-from-odysseus")
    async def compose_from_odysseus(data: dict, owner: str = Depends(require_owner)):
        """Stage an Odysseus document or gallery image as a compose upload."""
        kind = str(data.get("kind") or "").strip().lower()
        item_id = str(data.get("id") or "").strip()
        if kind not in {"document", "gallery"} or not item_id:
            raise HTTPException(status_code=400, detail="Expected kind and id")
        try:
            from core.database import SessionLocal as _SL

            db = _SL()
            try:
                src = _load_odysseus_attachment_source(db, kind, item_id, owner)
                if "path" in src:

View on GitHub (pinned to f9235ebbf1)