{"record":{"id":"1ead0a4c6d293156","repo":"odysseus-dev/odysseus","slug":"file-not-found","errorCode":null,"errorMessage":"File not found","messagePattern":"File not found","errorType":"http","errorClass":"HTTPException","httpStatus":404,"severity":"error","filePath":"routes/email_routes.py","lineNumber":4058,"sourceCode":"            return {\"success\": False, \"error\": \"Mail operation failed\"}\n\n    def _safe_compose_filename(name: str, fallback: str = \"attachment\") -> str:\n        safe_name = re.sub(r\"[^\\w\\s\\-.]\", \"_\", Path(str(name or fallback)).name).strip(\". \")[:180]\n        return safe_name or fallback\n\n    def _stage_compose_bytes(filename: str, content: bytes) -> dict:\n        if len(content) > EMAIL_COMPOSE_UPLOAD_MAX_BYTES:\n            raise HTTPException(status_code=413, detail=\"Attachment too large\")\n        safe_name = _safe_compose_filename(filename)\n        token = f\"{uuid.uuid4().hex}_{safe_name}\"\n        filepath = COMPOSE_UPLOADS_DIR / token\n        with open(filepath, \"wb\") as f:\n            f.write(content)\n        return {\"success\": True, \"token\": token, \"filename\": safe_name, \"size\": len(content)}\n\n    def _stage_compose_file(filename: str, src: Path) -> dict:\n        if not src.exists() or not src.is_file():\n            raise HTTPException(status_code=404, detail=\"File not found\")\n        size = src.stat().st_size\n        if size > EMAIL_COMPOSE_UPLOAD_MAX_BYTES:\n            raise HTTPException(status_code=413, detail=\"Attachment too large\")\n        safe_name = _safe_compose_filename(filename)\n        token = f\"{uuid.uuid4().hex}_{safe_name}\"\n        dest = COMPOSE_UPLOADS_DIR / token\n        import shutil as _shutil\n        _shutil.copyfile(str(src), str(dest))\n        return {\"success\": True, \"token\": token, \"filename\": safe_name, \"size\": size}\n\n    def _load_odysseus_attachment_source(db, kind: str, item_id: str, owner: str):\n        from core.database import Document as _Doc, GalleryImage as _GI\n        from core.database import Session as _Sess\n\n        if kind == \"document\":\n            doc = db.query(_Doc).filter(_Doc.id == item_id, _Doc.is_active == True).first()\n            if not doc:\n                raise HTTPException(status_code=404, detail=\"Document not found\")","sourceCodeStart":4040,"sourceCodeEnd":4076,"githubUrl":"https://github.com/odysseus-dev/odysseus/blob/f9235ebbf13f693a6fd29ce70b097f6ec83705bf/routes/email_routes.py#L4040-L4076","documentation":"Error \"File 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":["Verify the file id is correct and the upload still exists.","Re-upload the file if it was removed, then retry."],"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-15T17:31:12.345Z"}