odysseus-dev/odysseus · error · HTTPException

Email not found

Error message

Email not found

What it means

404 guard for email-scoped endpoints: the message identified by uid (in the given folder/account) could not be fetched via IMAP — the UID does not exist, was expunged, or belongs to another folder/account state. Fires when clients hold stale UIDs after the mailbox changed server-side.

Solutions

  1. Refresh the email list; the message may have been moved or deleted.
  2. Verify the email id is correct for the selected account and folder.
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/9fd8edc7835c9eb2. Report an issue: GitHub.

Appendix: source

Thrown at routes/email_routes.py:3335

            return FileResponse(
                path=str(filepath),
                filename=filepath.name,
                media_type="application/octet-stream",
            )
        except Exception as e:
            logger.error(f"Failed to download attachment {uid}/{index}: {e}")
            return {"error": "Mail operation failed"}

    @router.get("/attachments-download/{uid}")
    async def download_all_attachments(uid: str, folder: str = Query("INBOX"), account_id: str | None = Query(None), owner: str = Depends(require_owner)):
        """Download all visible attachments for an email as a zip archive."""
        try:
            with _imap(account_id, owner=owner) as conn:
                conn.select(_q(folder), readonly=True)
                status, msg_data = _imap_uid_fetch(conn, uid, "(RFC822)")
            if status != "OK":
                raise HTTPException(status_code=404, detail="Email not found")
            raw = msg_data[0][1]
            msg = email_mod.message_from_bytes(raw)
            attachments = [
                att for att in _list_attachments_from_msg(msg)
                if not _is_likely_signature_image_attachment(att)
            ]
            if not attachments:
                raise HTTPException(status_code=404, detail="No downloadable attachments")

            target_dir = attachment_extract_dir(folder, uid)
            zip_buf = io.BytesIO()
            used_names: dict[str, int] = {}
            with zipfile.ZipFile(zip_buf, "w", compression=zipfile.ZIP_DEFLATED) as zf:
                for att in attachments:
                    idx = att.get("index")
                    if idx is None:
                        continue
                    filepath = _extract_attachment_to_disk(msg, int(idx), target_dir)

View on GitHub (pinned to f9235ebbf1)