{"record":{"id":"9fd8edc7835c9eb2","repo":"odysseus-dev/odysseus","slug":"email-not-found","errorCode":null,"errorMessage":"Email not found","messagePattern":"Email not found","errorType":"http","errorClass":"HTTPException","httpStatus":404,"severity":"error","filePath":"routes/email_routes.py","lineNumber":3335,"sourceCode":"\n            return FileResponse(\n                path=str(filepath),\n                filename=filepath.name,\n                media_type=\"application/octet-stream\",\n            )\n        except Exception as e:\n            logger.error(f\"Failed to download attachment {uid}/{index}: {e}\")\n            return {\"error\": \"Mail operation failed\"}\n\n    @router.get(\"/attachments-download/{uid}\")\n    async def download_all_attachments(uid: str, folder: str = Query(\"INBOX\"), account_id: str | None = Query(None), owner: str = Depends(require_owner)):\n        \"\"\"Download all visible attachments for an email as a zip archive.\"\"\"\n        try:\n            with _imap(account_id, owner=owner) as conn:\n                conn.select(_q(folder), readonly=True)\n                status, msg_data = _imap_uid_fetch(conn, uid, \"(RFC822)\")\n            if status != \"OK\":\n                raise HTTPException(status_code=404, detail=\"Email not found\")\n            raw = msg_data[0][1]\n            msg = email_mod.message_from_bytes(raw)\n            attachments = [\n                att for att in _list_attachments_from_msg(msg)\n                if not _is_likely_signature_image_attachment(att)\n            ]\n            if not attachments:\n                raise HTTPException(status_code=404, detail=\"No downloadable attachments\")\n\n            target_dir = attachment_extract_dir(folder, uid)\n            zip_buf = io.BytesIO()\n            used_names: dict[str, int] = {}\n            with zipfile.ZipFile(zip_buf, \"w\", compression=zipfile.ZIP_DEFLATED) as zf:\n                for att in attachments:\n                    idx = att.get(\"index\")\n                    if idx is None:\n                        continue\n                    filepath = _extract_attachment_to_disk(msg, int(idx), target_dir)","sourceCodeStart":3317,"sourceCodeEnd":3353,"githubUrl":"https://github.com/odysseus-dev/odysseus/blob/f9235ebbf13f693a6fd29ce70b097f6ec83705bf/routes/email_routes.py#L3317-L3353","documentation":"Error \"Email 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 email list; the message may have been moved or deleted.","Verify the email id is correct for the selected account and folder."],"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"}